Catrope has uploaded a new change for review.

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

Change subject: Fix craziness in template dialog focusing
......................................................................

Fix craziness in template dialog focusing

setMode() is called multiple times, but it didn't
check whether the mode being set was already set.
Because it's a setter, make it idempotent.

This fixes the problem where the first input will
be focused first, then blurred later, but it
introduces a new problem because the label for
the 'mode' ActionWidget is set from setMode().
To solve that, factor the setting of this label
out into its own function and call it on setup.

Bug: 73138
Change-Id: I9bb127f22f6c0b745b393c523ec42f320fc85cf3
---
M modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
1 file changed, 30 insertions(+), 20 deletions(-)


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

diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
index 2054cef..67e8c53 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
@@ -225,28 +225,24 @@
        if ( !modeCssClasses[mode] ) {
                mode = 'multiple';
        }
-       this.mode = mode;
-       single = mode === 'single';
-       if ( this.$content ) {
-               for ( name in modeCssClasses ) {
-                       this.$content.toggleClass( modeCssClasses[name], name 
=== mode );
+
+       if ( this.mode !== mode ) {
+               this.mode = mode;
+               single = mode === 'single';
+               if ( this.$content ) {
+                       for ( name in modeCssClasses ) {
+                               this.$content.toggleClass( 
modeCssClasses[name], name === mode );
+                       }
                }
+               this.setSize( single ? 'medium' : 'large' );
+               this.bookletLayout.toggleOutline( !single );
+               this.updateTitle();
+               this.updateModeActionLabel();
+
+               // HACK blur any active input so that its dropdown will be 
hidden and won't end
+               // up being mispositioned
+               this.$content.find( 'input:focus' ).blur();
        }
-       this.setSize( single ? 'medium' : 'large' );
-       this.bookletLayout.toggleOutline( !single );
-       this.updateTitle();
-
-       this.actions.forEach( { actions: [ 'mode' ] }, function ( action ) {
-               action.setLabel(
-                       single ?
-                               ve.msg( 
'visualeditor-dialog-transclusion-multiple-mode' ) :
-                               ve.msg( 
'visualeditor-dialog-transclusion-single-mode' )
-               );
-       } );
-
-       // HACK blur any active input so that its dropdown will be hidden and 
won't end
-       // up being mispositioned
-       this.$content.find( 'input:focus' ).blur();
 };
 
 /**
@@ -259,6 +255,19 @@
                // Parent method
                ve.ui.MWTransclusionDialog.super.prototype.updateTitle.call( 
this );
        }
+};
+
+/**
+ * Update the label for the 'mode' action
+ */
+ve.ui.MWTransclusionDialog.prototype.updateModeActionLabel = function () {
+       this.actions.forEach( { actions: [ 'mode' ] }, function ( action ) {
+               action.setLabel(
+                       this.mode === 'single' ?
+                               ve.msg( 
'visualeditor-dialog-transclusion-multiple-mode' ) :
+                               ve.msg( 
'visualeditor-dialog-transclusion-single-mode' )
+               );
+       } );
 };
 
 /**
@@ -344,6 +353,7 @@
        return ve.ui.MWTransclusionDialog.super.prototype.getSetupProcess.call( 
this, data )
                .next( function () {
                        this.setMode( 'single' );
+                       this.updateModeActionLabel();
                        this.actions.setAbilities( { mode: false } );
                }, this );
 };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9bb127f22f6c0b745b393c523ec42f320fc85cf3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>

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

Reply via email to