From 3d9b49056e432080eee754bf80e2eab4ca7256c3 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 16 Aug 2017 16:04:40 -0600 Subject: [PATCH] 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. --- src/text-editor-component.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index b38f34cc5..67ed06f65 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -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) {