Trevor Parscal has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/68130


Change subject: Actually fix bug 48556
......................................................................

Actually fix bug 48556

Turns out that by skipping the last item, the following logic which depended on 
that item being in the existing items list failed to keep it's grubby hands off 
it.

Yes, I know I +2'd it. Shame on me too.

Bug: 48556
Bug: 48565
I93ce05f7cbb28313a3f0827539f0528c366aeb7e

Change-Id: If48e001b92c217bee0a35b6da41d1c1ff0e3271c
---
M modules/ve/ui/widgets/ve.ui.MWCategoryInputWidget.js
1 file changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/30/68130/1

diff --git a/modules/ve/ui/widgets/ve.ui.MWCategoryInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.MWCategoryInputWidget.js
index 6da9701..f708203 100644
--- a/modules/ve/ui/widgets/ve.ui.MWCategoryInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.MWCategoryInputWidget.js
@@ -106,8 +106,7 @@
                matchingCategories = data || [];
 
        // Existing categories
-       // bug 48556: Don't offer the very last category in the list here, so 
go up to .length - 1
-       for ( i = 0, len = existingCategories.length - 1; i < len; i++ ) {
+       for ( i = 0, len = existingCategories.length; i < len; i++ ) {
                item = existingCategories[i];
                // Verify that item starts with category.value
                if ( item.lastIndexOf( category.value, 0 ) === 0 ) {
@@ -121,7 +120,7 @@
        for ( i = 0, len = matchingCategories.length; i < len; i++ ) {
                item = matchingCategories[i];
                if (
-                       existingCategoryItems.indexOf( item ) === -1 &&
+                       ve.indexOf( item, existingCategoryItems ) === -1 &&
                        item.lastIndexOf( category.value, 0 ) === 0
                ) {
                        if ( item === category.value ) {
@@ -133,6 +132,15 @@
        // New category
        if ( !exactMatch ) {
                newCategoryItems.push( category.value );
+       }
+
+       // bug 48556: Don't actually offer to move the very last category in 
the list - we kept it in
+       // the list thus far so that other lists would not grab it for 
themselves, but now it's time to
+       // say goodbye
+       if (
+               existingCategoryItems[existingCategoryItems.length - 1] ===
+                       existingCategories[existingCategories.length - 1] ) {
+               existingCategoryItems.pop();
        }
 
        // Add sections for non-empty groups
@@ -158,8 +166,8 @@
                items.push( new ve.ui.MenuSectionItemWidget(
                        'matchingCategories', { '$$': menu$$, 'label': ve.msg( 
'visualeditor-dialog-meta-categories-input-matchingcategorieslabel' ) }
                ) );
-               for ( i = 0, len = matchingCategories.length; i < len; i++ ) {
-                       item = matchingCategories[i];
+               for ( i = 0, len = matchingCategoryItems.length; i < len; i++ ) 
{
+                       item = matchingCategoryItems[i];
                        items.push( new ve.ui.MenuItemWidget( item, { '$$': 
menu$$, 'label': item } ) );
                }
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If48e001b92c217bee0a35b6da41d1c1ff0e3271c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <tpars...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to