DLynch has uploaded a new change for review.
https://gerrit.wikimedia.org/r/250646
Change subject: Forcibly trigger a selection when using a Tool, to close
inspectors
......................................................................
Forcibly trigger a selection when using a Tool, to close inspectors
Currently, if you have an inspector open and try to use any Tool that
does a replace (all the "format" tools are good candidates) it'll do
the Tool's edit... and then emit a selection-changed event that asks
the inspector to close. But that pops staging... which undoes the
edit... but then other setTimeout'd code expects the edit to have
happened.
The simple solution seems to be to do something that'll close all open
inspectors _before_ the Tool gets to work. Because the whole thing is
caught up in a nest of setTimeouts, the easy way to do this seems to
just be to trigger a "the selection changed to whatever the current
selection is" event, and throw the actual Tool command into its own
fairly slow setTimeout.
Bug: T76717
Change-Id: I76fcd5d431b753d3e362d365aa2c0ca4e0a4b700
---
M src/ui/ve.ui.Tool.js
1 file changed, 13 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/46/250646/1
diff --git a/src/ui/ve.ui.Tool.js b/src/ui/ve.ui.Tool.js
index a3fe850..cad12e9 100644
--- a/src/ui/ve.ui.Tool.js
+++ b/src/ui/ve.ui.Tool.js
@@ -81,7 +81,19 @@
ve.ui.Tool.prototype.onSelect = function () {
var command = this.getCommand();
if ( command instanceof ve.ui.Command ) {
- command.execute( this.toolbar.getSurface() );
+ // Emit a selection event, to warn the context that it should
close any inspectors
+ // that are open. This is needed because closing inspectors
sometimes causes a
+ // popStaging call... which interacts poorly if the reason
they're closing is that
+ // you just executed a command that made a change which it
actually wants to stick
+ // around. (The "select" change fired by commiting a
transaction will eventually
+ // close all inspectors if nothing else happens.)
+ this.toolbar.getSurface().getModel().emit( 'select',
this.toolbar.getSurface().getModel().selection.clone() );
+ // The chain of events that results in the inspectors closing
goes a few layers of
+ // async deep. So, throw a fairly long delay in here to avoid
running until after
+ // they're all done.
+ setTimeout( function () {
+ command.execute( this.toolbar.getSurface() );
+ }.bind( this ), 100 );
}
if ( this.constructor.static.deactivateOnSelect ) {
this.setActive( false );
--
To view, visit https://gerrit.wikimedia.org/r/250646
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I76fcd5d431b753d3e362d365aa2c0ca4e0a4b700
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits