From dd622918983754013097e530a0f317660d98a855 Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Mon, 13 May 2024 14:03:19 +0800 Subject: [PATCH] Avoid side effects for Enter/Backspace when composing in Safari (#4201) Co-authored-by: odex --- packages/quill/src/modules/keyboard.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/quill/src/modules/keyboard.ts b/packages/quill/src/modules/keyboard.ts index 3301046410..7941b370f5 100644 --- a/packages/quill/src/modules/keyboard.ts +++ b/packages/quill/src/modules/keyboard.ts @@ -173,6 +173,13 @@ class Keyboard extends Module { listen() { this.quill.root.addEventListener('keydown', (evt) => { if (evt.defaultPrevented || evt.isComposing) return; + + // evt.isComposing is false when pressing Enter/Backspace when composing in Safari + // https://bugs.webkit.org/show_bug.cgi?id=165004 + const isComposing = + evt.keyCode === 229 && (evt.key === 'Enter' || evt.key === 'Backspace'); + if (isComposing) return; + const bindings = (this.bindings[evt.key] || []).concat( this.bindings[evt.which] || [], );