EditCheck: Close any existing edit check dialog before opening onBeforeSave list

Depends-On: Ib58b05fab39bcdc7d68b84ae235cfff775d7712c
Change-Id: I04e6b209935756d6e56d479ec09f341463622acb
This commit is contained in:
Ed Sanders 2024-12-12 14:12:03 +00:00
parent e9c7503c72
commit 414e5d29ed

View file

@ -156,42 +156,45 @@ if ( mw.config.get( 'wgVisualEditorConfig' ).editCheck || mw.editcheck.ecenable
} }
saveProcess.next( () => { saveProcess.next( () => {
toolbar.toggle( false );
target.onContainerScroll();
// surface.executeCommand( 'editCheckDialogBeforeSave' );
const windowAction = ve.ui.actionFactory.create( 'window', surface, 'check' ); const windowAction = ve.ui.actionFactory.create( 'window', surface, 'check' );
return windowAction.open( 'editCheckDialog', { listener: 'onBeforeSave', reviewMode: true } ) // .always is not chainable
.then( ( instance ) => instance.closing ) return windowAction.close( 'editCheckDialog' ).closed.then( () => {}, () => {} ).then( () => {
.then( ( data ) => { toolbar.toggle( false );
reviewToolbar.$element.remove(); target.onContainerScroll();
toolbar.toggle( true ); // surface.executeCommand( 'editCheckDialogBeforeSave' );
target.toolbar = toolbar; return windowAction.open( 'editCheckDialog', { listener: 'onBeforeSave', reviewMode: true } )
if ( $contextContainer ) { .then( ( instance ) => instance.closing )
surface.context.popup.$container = $contextContainer; .then( ( data ) => {
surface.context.popup.containerPadding = contextPadding; reviewToolbar.$element.remove();
} toolbar.toggle( true );
// Creating a new PositionedTargetToolbar stole the target.toolbar = toolbar;
// toolbar windowmanagers, so we need to make the if ( $contextContainer ) {
// original toolbar reclaim them: surface.context.popup.$container = $contextContainer;
toolbar.disconnect( target ); surface.context.popup.containerPadding = contextPadding;
target.setupToolbar( surface ); }
target.onContainerScroll(); // Creating a new PositionedTargetToolbar stole the
// toolbar windowmanagers, so we need to make the
// original toolbar reclaim them:
toolbar.disconnect( target );
target.setupToolbar( surface );
target.onContainerScroll();
if ( data ) { if ( data ) {
const delay = ve.createDeferred(); const delay = ve.createDeferred();
// If they inserted, wait 2 seconds on desktop // If they inserted, wait 2 seconds on desktop
// before showing save dialog to make sure insertions are finialized // before showing save dialog to make sure insertions are finialized
setTimeout( () => { setTimeout( () => {
ve.track( 'counter.editcheck.preSaveChecksCompleted' ); ve.track( 'counter.editcheck.preSaveChecksCompleted' );
delay.resolve(); delay.resolve();
}, !OO.ui.isMobile() && data.action !== 'reject' ? 2000 : 0 ); }, !OO.ui.isMobile() && data.action !== 'reject' ? 2000 : 0 );
return delay.promise(); return delay.promise();
} else { } else {
// closed via "back" or otherwise // closed via "back" or otherwise
ve.track( 'counter.editcheck.preSaveChecksAbandoned' ); ve.track( 'counter.editcheck.preSaveChecksAbandoned' );
return ve.createDeferred().reject().promise(); return ve.createDeferred().reject().promise();
} }
} ); } );
} );
} ); } );
} else { } else {
// Counterpart to earlier preSaveChecksShown, for use in tracking // Counterpart to earlier preSaveChecksShown, for use in tracking