From 598cb943de35d4a1512c11600113485bcb8af7d1 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 14 Jan 2021 15:39:17 +0000 Subject: [PATCH] MWSaveDialog: Restore focus to edit summary widget after resize Change-Id: I1fc1e43d947e9e8472a470bb5eabf67fda07be5d --- modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js index 989ef8b74e..b6edf540bf 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js @@ -472,9 +472,10 @@ ve.ui.MWSaveDialog.prototype.swapPanel = function ( panel, noFocus ) { * @param {Object} [options] * @param {boolean} [options.wrap="warning"] Whether to wrap the message in a paragraph and if * so, how. One of "warning", "error" or false. + * @return {jQuery.Promise} Promise which resolves when the message has been shown, rejects if no new message shown. */ ve.ui.MWSaveDialog.prototype.showMessage = function ( name, message, options ) { - var $message; + var $message, promise; if ( !this.messages[ name ] ) { options = options || {}; if ( options.wrap === undefined ) { @@ -497,15 +498,18 @@ ve.ui.MWSaveDialog.prototype.showMessage = function ( name, message, options ) { // FIXME: Use CSS transitions // eslint-disable-next-line no-jquery/no-slide - $message.slideDown( { + promise = $message.slideDown( { duration: 250, progress: this.updateSize.bind( this ) - } ); + } ).promise(); this.swapPanel( 'save' ); this.messages[ name ] = $message; + + return promise; } + return ve.createDeferred().reject().promise(); }; /** @@ -617,7 +621,10 @@ ve.ui.MWSaveDialog.prototype.initialize = function () { new ve.ui.Trigger( ve.ui.commandHelpRegistry.lookup( 'dialogConfirm' ).shortcuts[ 0 ] ).getMessage() ), { wrap: false } - ); + ).then( function () { + // Restore focus after potential window resize + dialog.editSummaryInput.focus(); + } ); } ); // Limit length, and display the remaining characters this.editSummaryInput.$input.codePointLimit( this.editSummaryCodePointLimit );