Skip to content

Commit

Permalink
Only flush the selection when the editor view has focus
Browse files Browse the repository at this point in the history
Just as 94a7758 accounts for cases where the editor blurs without losing
the selection, account for the corresponding state when flushing wherein
the editor has the selection but not the focus.

If the editor view does not have focus, then it will set the selection
when it regains focus.
  • Loading branch information
tilgovi authored and marijnh committed Apr 26, 2022
1 parent 3c63b50 commit 20a45bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/domobserver.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import browser from "./browser"
import {domIndex, isEquivalentPosition} from "./dom"
import {hasFocusAndSelection, hasSelection, selectionToDOM} from "./selection"
import {hasFocusAndSelection, selectionToDOM} from "./selection"

const observeOptions = {
childList: true,
Expand Down Expand Up @@ -145,7 +145,7 @@ export class DOMObserver {
}

let sel = this.view.root.getSelection()
let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasSelection(this.view) && !this.ignoreSelectionChange(sel)
let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(this.view) && !this.ignoreSelectionChange(sel)

let from = -1, to = -1, typeOver = false, added = []
if (this.view.editable) {
Expand Down

0 comments on commit 20a45bb

Please sign in to comment.