From 414e5d29ed8b796ec6e8eea63b672bff4e3546a5 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 12 Dec 2024 14:12:03 +0000 Subject: [PATCH] EditCheck: Close any existing edit check dialog before opening onBeforeSave list Depends-On: Ib58b05fab39bcdc7d68b84ae235cfff775d7712c Change-Id: I04e6b209935756d6e56d479ec09f341463622acb --- editcheck/modules/init.js | 71 ++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 34 deletions(-) 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