mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Fix some behaviour when user aborts VE loading with escape
* Pass 'noPrompt' to #tryTeardown * #loadFail gets triggered by the data promise being aborted, so if 'activating' has been cleared at this point, don't prompt about there being load error. * Retry/cancel dialog assumed you were coming from a wikitext editor. Rewrite the logic to handle teardown the target if the user is coming from read mode. Change-Id: If9e5d1fbf00f8359f4d06fe7fc3064cc7e349bc9
This commit is contained in:
parent
b37d95244b
commit
fb8815f658
|
@ -702,6 +702,12 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( code, errorDetai
|
|||
return;
|
||||
}
|
||||
|
||||
if ( !this.activating ) {
|
||||
// Load failed after activation abandoned (e.g. user pressed escaped).
|
||||
// Nothing more to do.
|
||||
return;
|
||||
}
|
||||
|
||||
var $confirmPromptMessage = this.extractErrorMessages( errorDetails );
|
||||
|
||||
OO.ui.confirm( $confirmPromptMessage, {
|
||||
|
@ -711,16 +717,21 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( code, errorDetai
|
|||
]
|
||||
} ).done( function ( confirmed ) {
|
||||
if ( confirmed ) {
|
||||
// Retry load
|
||||
target.load();
|
||||
} else if ( $( '#wpTextbox1' ).length && !target.isModeAvailable( 'source' ) ) {
|
||||
// If we're switching from the wikitext editor, just deactivate
|
||||
// don't try to switch back to it fully, that'd discard changes.
|
||||
target.tryTeardown( true );
|
||||
} else {
|
||||
target.activatingDeferred.reject();
|
||||
// TODO: Some sort of progress bar?
|
||||
target.wikitextFallbackLoading = true;
|
||||
target.switchToWikitextEditor( false );
|
||||
// User pressed cancel
|
||||
if ( target.getSurface() ) {
|
||||
// Switching from VE source mode
|
||||
target.activatingDeferred.reject();
|
||||
// TODO: Some sort of progress bar?
|
||||
target.wikitextFallbackLoading = true;
|
||||
target.switchToWikitextEditor( false );
|
||||
} else {
|
||||
// We're switching from read mode or the 2010 wikitext editor:
|
||||
// just give up and stay where you are
|
||||
target.tryTeardown( true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
@ -878,7 +889,7 @@ ve.init.mw.DesktopArticleTarget.prototype.onDocumentKeyDown = function ( e ) {
|
|||
if ( toolbarDialogs.getCurrentWindow() ) {
|
||||
toolbarDialogs.getCurrentWindow().close();
|
||||
} else {
|
||||
target.tryTeardown( false, 'navigate-read' );
|
||||
target.tryTeardown( true, 'navigate-read' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue