Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/159807

Change subject: Bound onDocumentMouseUp to the entire document on mousedown
......................................................................

Bound onDocumentMouseUp to the entire document on mousedown

Otherwise a mouseup outside the surface is not detected.

Bug: 59822
Change-Id: I92b34624f84c55c5a6630e464c685d8fd83c4f43
---
M src/ce/ve.ce.Surface.js
1 file changed, 5 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/07/159807/1

diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 4651047..4f2f3ff 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -73,12 +73,13 @@
                { select: 'onModelSelect', documentUpdate: 
'onModelDocumentUpdate' }
        );
 
+       this.onDocumentMouseUpHandler = ve.bind( this.onDocumentMouseUp, this );
        $documentNode = this.getDocument().getDocumentNode().$element;
        $documentNode.on( {
                // mouse events shouldn't be sequenced as the event sequencer
                // is detached on blur
                mousedown: ve.bind( this.onDocumentMouseDown, this ),
-               mouseup: ve.bind( this.onDocumentMouseUp, this ),
+               // mouseup is bound to the whole document on mousedown
                mousemove: ve.bind( this.onDocumentMouseMove, this ),
                cut: ve.bind( this.onCut, this ),
                copy: ve.bind( this.onCopy, this )
@@ -636,8 +637,8 @@
        // Remember the mouse is down
        this.dragging = true;
 
-       // Old code to figure out if user clicked inside the document or not - 
leave it here for now
-       // this.$( e.target ).closest( '.ve-ce-documentNode' ).length === 0
+       // Bind mouseup to the whole document in case of dragging out of the 
surface
+       this.$document.on( 'mouseup', this.onDocumentMouseUpHandler );
 
        if ( e.which === 1 ) {
                this.surfaceObserver.stopTimerLoop();
@@ -669,6 +670,7 @@
  * @fires selectionEnd
  */
 ve.ce.Surface.prototype.onDocumentMouseUp = function ( e ) {
+       this.$document.off( 'mouseup', this.onDocumentMouseUpHandler );
        this.surfaceObserver.startTimerLoop();
        // TODO: guard with incRenderLock?
        this.surfaceObserver.pollOnce();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I92b34624f84c55c5a6630e464c685d8fd83c4f43
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