Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid re-composition if selection is non-empty, or on double-tap #7008

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/input/ContentEditableInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default class ContentEditableInput {
}
})

on(div, "touchstart", () => input.forceCompositionEnd())
on(div, "touchstart", () => {
input.forceCompositionEnd()
input.lastTap = +new Date()
})

on(div, "input", () => {
if (!this.composing) this.readFromDOMSoon()
Expand Down Expand Up @@ -349,6 +352,11 @@ export default class ContentEditableInput {
}
forceCompositionEnd() {
if (!this.composing) return
if (+new Date() < this.lastTap - 400) return
var startPos = cm.indexFromPos(cm.getCursor('from'))
var endPos = cm.indexFromPos(cm.getCursor('to'))
if (startPos !== endPos) return // do not force composition during selection

clearTimeout(this.readDOMTimeout)
this.composing = null
this.updateFromDOM()
Expand Down