Skip to content

Commit 581cc66

Browse files
committed
Avoid forcing composition for double-tap or non-empty selection
1 parent 349c8a6 commit 581cc66

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/input/ContentEditableInput.js

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

62-
on(div, "touchstart", () => input.forceCompositionEnd())
62+
on(div, "touchstart", () => {
63+
input.forceCompositionEnd()
64+
input.lastTap = +new Date()
65+
})
6366

6467
on(div, "input", () => {
6568
if (!this.composing) this.readFromDOMSoon()
@@ -349,6 +352,11 @@ export default class ContentEditableInput {
349352
}
350353
forceCompositionEnd() {
351354
if (!this.composing) return
355+
if (+new Date() < this.lastTap - 400) return
356+
var startPos = cm.indexFromPos(cm.getCursor('from'))
357+
var endPos = cm.indexFromPos(cm.getCursor('to'))
358+
if (startPos !== endPos) return // do not force composition during selection
359+
352360
clearTimeout(this.readDOMTimeout)
353361
this.composing = null
354362
this.updateFromDOM()

0 commit comments

Comments
 (0)