Suppress default-prevented composition events on compositionstart

This avoids creating a composition checkpoint and reverting to it on the
next keystroke, which causes the cursor to move.
This commit is contained in:
Nathan Sobo
2017-08-16 16:04:40 -06:00
parent 72322985d9
commit 3d9b49056e

View File

@@ -1671,17 +1671,6 @@ class TextEditorComponent {
// 4. compositionend fired
// 5. textInput fired; event.data == the completion string
didCompositionStart () {
if (this.getChromeVersion() === 56) {
this.getHiddenInput().value = ''
}
this.compositionCheckpoint = this.props.model.createCheckpoint()
if (this.accentedCharacterMenuIsOpen) {
this.props.model.selectLeft()
}
}
didCompositionUpdate (event) {
// Workaround for Chromium not preventing composition events when
// preventDefault is called on the keydown event that precipitated them.
if (this.lastKeydown && this.lastKeydown.defaultPrevented) {
@@ -1695,6 +1684,17 @@ class TextEditorComponent {
return
}
if (this.getChromeVersion() === 56) {
this.getHiddenInput().value = ''
}
this.compositionCheckpoint = this.props.model.createCheckpoint()
if (this.accentedCharacterMenuIsOpen) {
this.props.model.selectLeft()
}
}
didCompositionUpdate (event) {
if (this.getChromeVersion() === 56) {
process.nextTick(() => {
if (this.compositionCheckpoint != null) {