Robmoen has uploaded a new change for review.

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


Change subject: Fix for (Bug 46025) Current annotation was being nullified.
......................................................................

Fix for (Bug 46025) Current annotation was being nullified.

MWLinkTargetInputWidget annotation property was being killed
on populateMenu.

Other changes:
* Removed calls to sanitize on subclasses setValue methods
  as those methods call the parent class method which already
  sanitizes input.

Change-Id: I169dd58a06122122f187f9d751076ef56b255558
---
M modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
M modules/ve/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
2 files changed, 6 insertions(+), 10 deletions(-)


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

diff --git a/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
index bfe31fd..70c4d3f 100644
--- a/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
@@ -65,8 +65,9 @@
        this.annotation = annotation;
 
        // Call parent method
+
        ve.ui.TextInputWidget.prototype.setValue.call(
-               this, this.sanitizeValue( this.getTargetFromAnnotation( 
annotation ) )
+               this, this.getTargetFromAnnotation( annotation )
        );
 
        return this;
diff --git a/modules/ve/ui/widgets/ve.ui.MWLinkTargetInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
index 65d8a2b..3c1deb9 100644
--- a/modules/ve/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
@@ -44,8 +44,7 @@
                'blur': ve.bind( this.onBlur, this )
        } );
        this.menu.on( 'select', ve.bind( this.onMenuItemSelect, this ) );
-       this.on( 'change', ve.bind( this.onChange, this ) );
-
+       this.addListenerMethods( this, {'change': 'onChange'} );
        // Initialization
        this.$.addClass( 've-ui-mwLinkTargetInputWidget' );
        this.menu.$.addClass( 've-ui-mwLinkTargetInputWidget-menu' );
@@ -104,9 +103,8 @@
 };
 
 /**
- * Set the value of the input.
+ * Opens the suggestion menu on input change.
  *
- * Overrides setValue to keep annotations in sync.
  *
  * @method
  * @param {string} value New value
@@ -124,10 +122,7 @@
  * @param {string} value New value
  */
 ve.ui.MWLinkTargetInputWidget.prototype.setValue = function ( value ) {
-       // Keep annotation in sync with value
-       value = this.sanitizeValue( value );
-
-       // Call parent method
+       // Keep annotation in sync with value, call parent method.
        ve.ui.TextInputWidget.prototype.setValue.call( this, value );
 };
 
@@ -187,6 +182,7 @@
        if ( !pageExists && ( !matchingPages || matchingPages.indexOf( 
this.value ) === -1 ) ) {
                items.push( new ve.ui.MenuItemWidget( this.value, internalLink, 
{ 'group': 'newPage' } ) );
        }
+
        if ( matchingPages ) {
                for ( i = 0, len = matchingPages.length; i < len; i++ ) {
                        internalLink = new ve.dm.MWInternalLinkAnnotation( { 
'title': matchingPages[i] } );
@@ -208,7 +204,6 @@
        this.menu.selectItem( this.menu.getItemFromData( this.annotation ), 
true );
        if ( !this.menu.getSelectedItem() ) {
                this.menu.selectItem( this.menu.getItemFromIndex( 0 ), true );
-               this.annotation = null;
        }
 
        return this;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I169dd58a06122122f187f9d751076ef56b255558
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Robmoen <rm...@wikimedia.org>

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

Reply via email to