DLynch has uploaded a new change for review.

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

Change subject: ve.ce.Surface: when setting selection just focus if focusTarget 
== activeElement
......................................................................

ve.ce.Surface: when setting selection just focus if focusTarget == activeElement

The common case for getting here is when pressing backspace when the cursor is
in the middle of a block of text (thus both are the same <div>), and we don't
want to scroll away from the caret.

Change-Id: I634d5db7df83c40a784a308a33f03b67518c999e
---
M src/ce/ve.ce.Surface.js
1 file changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/75/304575/1

diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 3b960ca..03d90a5 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -3383,7 +3383,11 @@
        // Setting a range doesn't give focus in all browsers so make sure this 
happens
        // Also set focus after range to prevent scrolling to top
        $focusTarget = $( newSel.focusNode ).closest( '[contenteditable=true]' 
);
-       if ( !OO.ui.contains( $focusTarget.get( 0 ), 
this.getElementDocument().activeElement, true ) ) {
+       if ( !OO.ui.contains( $focusTarget.get( 0 ), 
this.getElementDocument().activeElement ) ) {
+               // Note: contains *doesn't* include === here. This is desired, 
as the
+               // common case for getting here is when pressing backspace when 
the
+               // cursor is in the middle of a block of text (thus both are a 
<div>),
+               // and we don't want to scroll away from the caret.
                $focusTarget.focus();
        } else {
                // Scroll the node into view

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

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

Reply via email to