jenkins-bot has submitted this change and it was merged.

Change subject: Offer the typed text as a link suggestion if the page is valid
......................................................................


Offer the typed text as a link suggestion if the page is valid

Currently we only offer the normalised page title from the server
so 'iPhone' only suggests 'IPhone'. With this fix we offer the typed
text as the first suggestion if it matches via mw.Title, so 'iPhone'
suggests ['iPhone', 'IPhone', ...]

Bug: 50452
Change-Id: I05cc0cd19537cbfa682d7aac0f9640decea282b5
---
M modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
1 file changed, 6 insertions(+), 1 deletion(-)

Approvals:
  Catrope: Looks good to me, approved
  Jforrester: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js 
b/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
index 31044b2..dfe7f60 100644
--- a/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
@@ -105,8 +105,9 @@
                matchingPages = data,
                // If not found, run value through mw.Title to avoid treating a 
match as a
                // mismatch where normalisation would make them matching (bug 
48476)
+               pageExistsExact = ve.indexOf( this.value, matchingPages ) !== 
-1,
                pageExists =
-                       ve.indexOf( this.value, matchingPages ) !== -1 ||
+                       pageExistsExact ||
                        ve.indexOf( new mw.Title( this.value 
).getPrefixedText(), matchingPages ) !== -1;
 
        // External link
@@ -148,6 +149,10 @@
                        'matchingPages',
                        { '$$': menu$$, 'label': ve.msg( 
'visualeditor-linkinspector-suggest-matching-page' ) }
                ) );
+               // Offer the exact text as a suggestion if the page exists
+               if ( pageExists && !pageExistsExact ) {
+                       matchingPages.unshift( this.value );
+               }
                for ( i = 0, len = matchingPages.length; i < len; i++ ) {
                        items.push( new ve.ui.MenuItemWidget(
                                this.getInternalLinkAnnotationFromTitle( 
matchingPages[i] ),

-- 
To view, visit https://gerrit.wikimedia.org/r/82054
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I05cc0cd19537cbfa682d7aac0f9640decea282b5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to