Jforrester has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/396034 )

Change subject: Don't execute commands twice
......................................................................


Don't execute commands twice

Bug: T182270
Change-Id: Iecc15a744d9a4606f8e1c9a1d2641d0fe8191049
(cherry picked from commit 2a1316fccd9166131c659ce83fe37bb8d491b8c8)
---
M src/ui/ve.ui.Tool.js
1 file changed, 10 insertions(+), 7 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/src/ui/ve.ui.Tool.js b/src/ui/ve.ui.Tool.js
index 0a63bd1..c07290c 100644
--- a/src/ui/ve.ui.Tool.js
+++ b/src/ui/ve.ui.Tool.js
@@ -114,7 +114,6 @@
                        contextClosePromise = 
surface.context.inspector.close().closed;
                } else {
                        contextClosePromise = $.Deferred().resolve().promise();
-                       command.execute( surface );
                }
        }
        if ( this.constructor.static.deactivateOnSelect ) {
@@ -123,12 +122,16 @@
                // if the promise is slow.
                this.setActive( false );
        }
-       contextClosePromise.done( function () {
-               if ( !command.execute( surface ) ) {
-                       // If the command fails, ensure the tool is not active
-                       tool.setActive( false );
-               }
-       } );
+       if ( contextClosePromise ) {
+               // N.B. If contextClosePromise is already resolved, then the 
handler is called
+               // before the call to .done returns
+               contextClosePromise.done( function () {
+                       if ( !command.execute( surface ) ) {
+                               // If the command fails, ensure the tool is not 
active
+                               tool.setActive( false );
+                       }
+               } );
+       }
 };
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iecc15a744d9a4606f8e1c9a1d2641d0fe8191049
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: wmf/1.31.0-wmf.11
Gerrit-Owner: Jforrester <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to