Skip to content

Commit

Permalink
Don't mess with the selection when refocusing a text field
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Apr 29, 2020
1 parent a67ed9a commit 6890f98
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/display/update_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ function selectionSnapshot(cm) {
function restoreSelection(snapshot) {
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) return
snapshot.activeElt.focus()
if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
let sel = window.getSelection(), range = document.createRange()
range.setEnd(snapshot.anchorNode, snapshot.anchorOffset)
range.collapse(false)
Expand Down

0 comments on commit 6890f98

Please sign in to comment.