TitleWidget: Sort results correctly
authorEd Sanders <esanders@wikimedia.org>
Thu, 29 Oct 2015 13:18:42 +0000 (13:18 +0000)
committerEd Sanders <esanders@wikimedia.org>
Thu, 29 Oct 2015 13:18:42 +0000 (13:18 +0000)
Bug: T117039
Change-Id: Ie86c1751dacb5c32afe708b354809b914a54ea51

resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js

index 0ef5095..f764513 100644 (file)
                                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
                        }
                }
 
+               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)