Skip to content

Commit b470f24

Browse files
committed
Clear contentEditable selection when it can't be drawn
So that we don't leave a stray selection that'll be reset to some nonsense position by the DOM changes. Closes codemirror#4625
1 parent 168d228 commit b470f24

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/input/ContentEditableInput.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ export default class ContentEditableInput {
122122

123123
let start = posToDOM(this.cm, prim.from())
124124
let end = posToDOM(this.cm, prim.to())
125-
if (!start && !end) return
125+
if (!start && !end) {
126+
sel.removeAllRanges()
127+
return
128+
}
126129

127130
let view = this.cm.display.view
128131
let old = sel.rangeCount && sel.getRangeAt(0)

0 commit comments

Comments
 (0)