mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
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
This commit is contained in:
parent
f7b947f14c
commit
a86d824c56
|
@ -225,28 +225,24 @@ ve.ui.MWTransclusionDialog.prototype.setMode = function ( mode ) {
|
|||
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();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -261,6 +257,19 @@ ve.ui.MWTransclusionDialog.prototype.updateTitle = function () {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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' )
|
||||
);
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a part to the transclusion.
|
||||
*
|
||||
|
@ -344,6 +353,7 @@ ve.ui.MWTransclusionDialog.prototype.getSetupProcess = function ( data ) {
|
|||
return ve.ui.MWTransclusionDialog.super.prototype.getSetupProcess.call( this, data )
|
||||
.next( function () {
|
||||
this.setMode( 'single' );
|
||||
this.updateModeActionLabel();
|
||||
this.actions.setAbilities( { mode: false } );
|
||||
}, this );
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue