Mooeypoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/201632

Change subject: Close inspectors when dialog opens
......................................................................

Close inspectors when dialog opens

When we open a new dialog, make sure all inspectors are closing.

Bug: T93638
Change-Id: I5f50473a294eefbe0a83f34e29c49f729c5d45bf
---
M src/ui/actions/ve.ui.WindowAction.js
1 file changed, 12 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/32/201632/1

diff --git a/src/ui/actions/ve.ui.WindowAction.js 
b/src/ui/actions/ve.ui.WindowAction.js
index 1e5ff33..bec277d 100644
--- a/src/ui/actions/ve.ui.WindowAction.js
+++ b/src/ui/actions/ve.ui.WindowAction.js
@@ -45,9 +45,10 @@
  * @return {boolean} Action was executed
  */
 ve.ui.WindowAction.prototype.open = function ( name, data, action ) {
-       var windowType = this.getWindowType( name ),
+       var currentInspector, inspectorWindowManager,
+               windowType = this.getWindowType( name ),
                windowManager = windowType && this.getWindowManager( windowType 
),
-               autoClosePromise = $.Deferred().resolve().promise(),
+               autoClosePromises = [],
                surface = this.surface,
                fragment = surface.getModel().getFragment( undefined, true ),
                dir = 
surface.getView().getDocument().getDirectionFromSelection( 
fragment.getSelection() ) ||
@@ -61,10 +62,17 @@
        if ( windowType === 'toolbar' || windowType === 'inspector' ) {
                data = ve.extendObject( data, { surface: surface } );
                // TODO: Make auto-close a window manager setting
-               autoClosePromise = windowManager.closeWindow( 
windowManager.getCurrentWindow() );
+               autoClosePromises.push( windowManager.closeWindow( 
windowManager.getCurrentWindow() ) );
        }
 
-       autoClosePromise.always( function () {
+       // If we're opening a dialog, close all inspectors first
+       if ( windowType === 'dialog' ) {
+               inspectorWindowManager = this.getWindowManager( 'inspector' );
+               currentInspector = inspectorWindowManager.getCurrentWindow();
+               autoClosePromises.push( inspectorWindowManager.closeWindow( 
currentInspector ) );
+       }
+
+       $.when.apply( $, autoClosePromises ).always( function () {
                windowManager.getWindow( name ).then( function ( win ) {
                        var opening = windowManager.openWindow( win, data );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/201632
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f50473a294eefbe0a83f34e29c49f729c5d45bf
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to