diff --git a/editcheck/modules/init.js b/editcheck/modules/init.js index 164daba9f3..551cf1a0b0 100644 --- a/editcheck/modules/init.js +++ b/editcheck/modules/init.js @@ -156,42 +156,45 @@ if ( mw.config.get( 'wgVisualEditorConfig' ).editCheck || mw.editcheck.ecenable } saveProcess.next( () => { - toolbar.toggle( false ); - target.onContainerScroll(); - // surface.executeCommand( 'editCheckDialogBeforeSave' ); const windowAction = ve.ui.actionFactory.create( 'window', surface, 'check' ); - return windowAction.open( 'editCheckDialog', { listener: 'onBeforeSave', reviewMode: true } ) - .then( ( instance ) => instance.closing ) - .then( ( data ) => { - reviewToolbar.$element.remove(); - toolbar.toggle( true ); - target.toolbar = toolbar; - if ( $contextContainer ) { - surface.context.popup.$container = $contextContainer; - surface.context.popup.containerPadding = contextPadding; - } - // 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(); + // .always is not chainable + return windowAction.close( 'editCheckDialog' ).closed.then( () => {}, () => {} ).then( () => { + toolbar.toggle( false ); + target.onContainerScroll(); + // surface.executeCommand( 'editCheckDialogBeforeSave' ); + return windowAction.open( 'editCheckDialog', { listener: 'onBeforeSave', reviewMode: true } ) + .then( ( instance ) => instance.closing ) + .then( ( data ) => { + reviewToolbar.$element.remove(); + toolbar.toggle( true ); + target.toolbar = toolbar; + if ( $contextContainer ) { + surface.context.popup.$container = $contextContainer; + surface.context.popup.containerPadding = contextPadding; + } + // 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 ) { - const delay = ve.createDeferred(); - // If they inserted, wait 2 seconds on desktop - // before showing save dialog to make sure insertions are finialized - setTimeout( () => { - ve.track( 'counter.editcheck.preSaveChecksCompleted' ); - delay.resolve(); - }, !OO.ui.isMobile() && data.action !== 'reject' ? 2000 : 0 ); - return delay.promise(); - } else { - // closed via "back" or otherwise - ve.track( 'counter.editcheck.preSaveChecksAbandoned' ); - return ve.createDeferred().reject().promise(); - } - } ); + if ( data ) { + const delay = ve.createDeferred(); + // If they inserted, wait 2 seconds on desktop + // before showing save dialog to make sure insertions are finialized + setTimeout( () => { + ve.track( 'counter.editcheck.preSaveChecksCompleted' ); + delay.resolve(); + }, !OO.ui.isMobile() && data.action !== 'reject' ? 2000 : 0 ); + return delay.promise(); + } else { + // closed via "back" or otherwise + ve.track( 'counter.editcheck.preSaveChecksAbandoned' ); + return ve.createDeferred().reject().promise(); + } + } ); + } ); } ); } else { // Counterpart to earlier preSaveChecksShown, for use in tracking