MWSaveDialog: only focus summary if we're on the save panel

Firefox throws exceptions when trying to focus hidden inputs. Using the
"preview" keyboard shortcut entirely bypasses the save panel, but the ready
process assumes it'll always be opened first.

Bug: T153958
Change-Id: Ifb3861116565e77c30b3874fe47889298c3ace6d
This commit is contained in:
David Lynch 2017-01-26 10:11:45 -06:00
parent fb48db7227
commit b976f2cf38

View file

@ -584,8 +584,14 @@ ve.ui.MWSaveDialog.prototype.getSetupProcess = function ( data ) {
ve.ui.MWSaveDialog.prototype.getReadyProcess = function ( data ) {
return ve.ui.MWSaveDialog.super.prototype.getReadyProcess.call( this, data )
.next( function () {
// This includes a #focus call
this.editSummaryInput.moveCursorToEnd();
// Support: Firefox
// In Firefox, trying to focus a hidden input will throw an
// exception. This would happen when opening the preview via
// keyboard shortcut.
if ( this.panels.getCurrentItem() === this.savePanel ) {
// This includes a #focus call
this.editSummaryInput.moveCursorToEnd();
}
}, this );
};