From 744b96df4601c16ebf86c456c9952872a44bd2c2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 11 Aug 2017 16:41:39 -0600 Subject: [PATCH] Suppress composition events default prevented on previous keydown This seems like a browser bug. --- src/text-editor-component.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 5764502ca..2f5817778 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1570,6 +1570,10 @@ class TextEditorComponent { } didTextInput (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) return + if (!this.isInputEnabled()) return event.stopPropagation() @@ -1626,7 +1630,6 @@ class TextEditorComponent { didKeypress (event) { this.lastKeydownBeforeKeypress = this.lastKeydown - this.lastKeydown = null // This cancels the accented character behavior if we type a key normally // with the menu open. @@ -1636,7 +1639,6 @@ class TextEditorComponent { didKeyup (event) { if (this.lastKeydownBeforeKeypress && this.lastKeydownBeforeKeypress.code === event.code) { this.lastKeydownBeforeKeypress = null - this.lastKeydown = null } } @@ -1662,6 +1664,10 @@ class TextEditorComponent { } 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) return + if (this.getChromeVersion() === 56) { process.nextTick(() => { if (this.compositionCheckpoint) {