Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit ae709c4

Browse files
authored
Avoid re-composition if selection is non-empty, or on double-tap
1 parent 349c8a6 commit ae709c4

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/input/ContentEditableInput.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,18 @@ export default class ContentEditableInput {
5959
}
6060
})
6161

62-
on(div, "touchstart", () => input.forceCompositionEnd())
62+
var lastTouchStart;
63+
on(div, "touchstart", function () {
64+
// do not force composition for double-tap, it breaks selection
65+
if (lastTouchStart < +new Date() + DOUBLECLICK_DELAY) return
66+
lastTouchStart = +new Date()
67+
68+
var startPos = cm.indexFromPos(cm.getCursor('from'))
69+
var endPos = cm.indexFromPos(cm.getCursor('to'))
70+
if (startPos !== endPos) return // do not force composition during selection
71+
72+
return input.forceCompositionEnd()
73+
})
6374

6475
on(div, "input", () => {
6576
if (!this.composing) this.readFromDOMSoon()

0 commit comments

Comments
 (0)