From 12dca65912d7055b1a06bbd8fa84d85263008800 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Thu, 8 Jul 2021 15:31:39 +0200 Subject: [PATCH] Delete last template search result, not a random one Because the API uses a generator, the search results are ordered alphabetically. The actual search result ranking is in a .index field. This code accidentially deleted the alphabetically lowest template instead of the least relevant one. Change-Id: I79de024feb569e9f06bedab908a6509a4d4fa99b --- modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js index 350909a00b..c41a70b4cc 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js @@ -235,7 +235,9 @@ ve.ui.MWTemplateTitleInputWidget.prototype.addExactMatch = function ( response ) newPage.index = 1; pages.unshift( newPage ); if ( pages.length > widget.limit ) { - pages.splice( widget.limit ); + pages.sort( function ( a, b ) { + return a.index - b.index; + } ).splice( widget.limit ); } } }