Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/336812 )

Change subject: Listen to mouseup events on documentNode for focus changes
......................................................................

Listen to mouseup events on documentNode for focus changes

When the selection is being collapsed inside itself we don't
know where the new selection is until mouseup.

Bug: T157499
Change-Id: I75e4529cc5f12c15d5fc96ccb21e9e491d95a054
---
M src/ce/ve.ce.Surface.js
1 file changed, 9 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/12/336812/1

diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 6690fc0..d0fc8ae 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -121,12 +121,17 @@
 
        this.onDocumentFocusInOutHandler = this.onDocumentFocusInOut.bind( this 
);
        this.$document.on( 'focusin focusout', this.onDocumentFocusInOutHandler 
);
-       // It is possible for a mousedown to clear the selection
-       // without triggering a focus change event (e.g. if the
-       // document has been programmatically blurred) so trigger
-       // a focus change to check if we still have a selection
+
        this.debounceFocusChange = ve.debounce( this.onFocusChange ).bind( this 
);
+       // If the document is blurred (but still has a selection) it is
+       // possible to clear the selection by clicking elsewhere without
+       // triggering a focus or blur event, so listen to mousedown globally.
        this.$document.on( 'mousedown', this.debounceFocusChange );
+       // It is possible that when focusin fires, the selection is not yet 
inside
+       // the document. This happens if the selection is being moved inside 
itself,
+       // e.g. the whole html page was previously selected, including the 
docuemntNode.
+       // In this case the selection is not moved until mouseup. T157499
+       this.$documentNode.on( 'mouseup', this.debounceFocusChange );
 
        this.$pasteTarget.add( this.$highlights ).on( {
                cut: this.onCut.bind( this ),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I75e4529cc5f12c15d5fc96ccb21e9e491d95a054
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

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

Reply via email to