From: Ed Sanders Date: Thu, 29 Oct 2015 13:18:42 +0000 (+0000) Subject: TitleWidget: Sort results correctly X-Git-Tag: 1.31.0-rc.0~9181^2 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=9238a1b7ecf7062cbf7e093abec0e1be0cc0ebf8;p=lhc%2Fweb%2Fwiklou.git TitleWidget: Sort results correctly Bug: T117039 Change-Id: Ie86c1751dacb5c32afe708b354809b914a54ea51 --- diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js index 0ef50950c0..f764513192 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js @@ -180,7 +180,9 @@ redirect: suggestionPage.redirect !== undefined, disambiguation: OO.getProp( suggestionPage, 'pageprops', 'disambiguation' ) !== undefined, imageUrl: OO.getProp( suggestionPage, 'thumbnail', 'source' ), - description: OO.getProp( suggestionPage, 'terms', 'description' ) + description: OO.getProp( suggestionPage, 'terms', 'description' ), + // sort index + index: suggestionPage.index }; // Throw away pages from wrong namespaces. This can happen when 'showRedirectTargets' is true @@ -201,6 +203,10 @@ } } + titles.sort( function ( a, b ) { + return pageData[ a ].index - pageData[ b ].index; + } ); + // If not found, run value through mw.Title to avoid treating a match as a // mismatch where normalisation would make them matching (bug 48476)