jenkins-bot has submitted this change and it was merged.
Change subject: Always refocus the paste target when a node is selected
......................................................................
Always refocus the paste target when a node is selected
The previous assumption was that if the paste target had a
selection it didn't need to be re-selected and focussed, however
it is possible for the paste target to keep a selection but lose
focus. As this event usually only fires when the paste target
loses focus, just remove the optimisation all together.
onFocusChange will ensure that no extra focus/blur events are emitted
(the reasoning given for this change in I466a64364).
Bug: 67178
Change-Id: I7c87b6da3aedf2923f75dc6f91c0d43b23847334
---
M modules/ve/ce/ve.ce.Surface.js
1 file changed, 14 insertions(+), 16 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 7876561..384dac3 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -1399,22 +1399,20 @@
// this function is called by the focus handler to restore a lost
selection state
if ( next ) {
rangySel = rangy.getSelection( this.getElementDocument() );
- if ( !ve.contains( this.$pasteTarget[0], rangySel.anchorNode,
true ) ) {
- // As FF won't fire a copy event with nothing selected,
make
- // a dummy selection of one space in the pasteTarget.
- // onCopy will ignore this native selection and use the
DM selection
- this.$pasteTarget.text( ' ' );
- rangyRange = rangy.createRange(
this.getElementDocument() );
- rangyRange.setStart( this.$pasteTarget[0], 0 );
- rangyRange.setEnd( this.$pasteTarget[0], 1 );
- rangySel.removeAllRanges();
- this.$pasteTarget[0].focus();
- rangySel.addRange( rangyRange, false );
- // Since the selection is no longer in the
documentNode, clear the SurfaceObserver's
- // selection state. Otherwise, if the user places the
selection back into the documentNode
- // in exactly the same place where it was before, the
observer won't consider that a change.
- this.surfaceObserver.clear();
- }
+ // As FF won't fire a copy event with nothing selected, make
+ // a dummy selection of one space in the pasteTarget.
+ // onCopy will ignore this native selection and use the DM
selection
+ this.$pasteTarget.text( ' ' );
+ rangyRange = rangy.createRange( this.getElementDocument() );
+ rangyRange.setStart( this.$pasteTarget[0], 0 );
+ rangyRange.setEnd( this.$pasteTarget[0], 1 );
+ rangySel.removeAllRanges();
+ this.$pasteTarget[0].focus();
+ rangySel.addRange( rangyRange, false );
+ // Since the selection is no longer in the documentNode, clear
the SurfaceObserver's
+ // selection state. Otherwise, if the user places the selection
back into the documentNode
+ // in exactly the same place where it was before, the observer
won't consider that a change.
+ this.surfaceObserver.clear();
}
// If there is no focused node, use native selection, but ignore the
selection if
--
To view, visit https://gerrit.wikimedia.org/r/142527
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7c87b6da3aedf2923f75dc6f91c0d43b23847334
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits