jenkins-bot has submitted this change and it was merged.
Change subject: Remove and restore selection for non-isolated dialogs
......................................................................
Remove and restore selection for non-isolated dialogs
In non-isolated mode the only way to prevent accidental typing in
the document is by removing the native selection, so do this.
This unavoidably sets the model selection to null, so when the dialog
closes, restore the selection if it hasn't been already by an action.
Bug: 73097
Change-Id: I93f741734ff3d46397c1278c500ae3c124a3a14f
(cherry picked from commit 6be79d9ae7bc728ee1d80e82c53511a9d1da6176)
---
M src/ui/actions/ve.ui.WindowAction.js
M src/ui/ve.ui.Surface.js
2 files changed, 19 insertions(+), 24 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/ui/actions/ve.ui.WindowAction.js
b/src/ui/actions/ve.ui.WindowAction.js
index 8eb3124..c41e3fe 100644
--- a/src/ui/actions/ve.ui.WindowAction.js
+++ b/src/ui/actions/ve.ui.WindowAction.js
@@ -45,19 +45,32 @@
ve.ui.WindowAction.prototype.open = function ( name, data ) {
var windowManager,
windowClass = ve.ui.windowFactory.lookup( name ),
- fragment = this.surface.getModel().getFragment( undefined, true
),
- dir =
this.surface.getView().getDocument().getDirectionFromSelection(
fragment.getSelection() ) ||
- this.surface.getModel().getDocument().getDir();
+ surface = this.surface,
+ fragment = surface.getModel().getFragment( undefined, true ),
+ dir =
surface.getView().getDocument().getDirectionFromSelection(
fragment.getSelection() ) ||
+ surface.getModel().getDocument().getDir();
data = ve.extendObject( { dir: dir }, data, { fragment: fragment } );
if ( windowClass ) {
if ( windowClass.prototype instanceof ve.ui.FragmentInspector )
{
- windowManager =
this.surface.getContext().getInspectors();
+ windowManager = surface.getContext().getInspectors();
+ windowManager.openWindow( name, data );
} else if ( windowClass.prototype instanceof OO.ui.Dialog ) {
- windowManager = this.surface.getDialogs();
+ // For non-isolated dialogs, remove the selection and
re-apply on close
+ surface.getView().nativeSelection.removeAllRanges();
+ windowManager = surface.getDialogs();
+ windowManager.openWindow( name, data ).then( function (
opened ) {
+ opened.then( function ( closing ) {
+ closing.then( function () {
+ // Check the dialog didn't
modify the selection before restoring from fragment
+ if (
surface.getModel().getSelection().isNull() ) {
+ fragment.select();
+ }
+ } );
+ } );
+ } );
}
- windowManager.openWindow( name, data );
}
};
diff --git a/src/ui/ve.ui.Surface.js b/src/ui/ve.ui.Surface.js
index 600537d..6e4656d 100644
--- a/src/ui/ve.ui.Surface.js
+++ b/src/ui/ve.ui.Surface.js
@@ -50,9 +50,6 @@
this.context = this.createContext();
this.filibuster = null;
- // Events
- this.dialogs.connect( this, { closing: 'onDialogClosing' } );
-
// Initialization
this.$menus.append( this.context.$element );
this.$element
@@ -118,21 +115,6 @@
// Let others know we have been destroyed
this.emit( 'destroy' );
-};
-
-/**
- * Handle dialog teardown events
- */
-ve.ui.Surface.prototype.onDialogClosing = function ( win, closing ) {
- var surface = this;
- closing.progress( function ( data ) {
- if ( data.state === 'teardown' ) {
- // Return focus to view
- surface.getView().focus();
- // Re-assert selection
- surface.getModel().getFragment().select();
- }
- } );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/171882
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I93f741734ff3d46397c1278c500ae3c124a3a14f
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: wmf/1.25wmf7
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[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