Skip to content

Commit

Permalink
Avoid side effects for Enter/Backspace when composing in Safari (slab…
Browse files Browse the repository at this point in the history
…#4201)

Co-authored-by: odex <odex_2100@outlook.com>
  • Loading branch information
luin and odex21 committed May 13, 2024
1 parent 2391107 commit dd62291
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/quill/src/modules/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ class Keyboard extends Module<KeyboardOptions> {
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] || [],
);
Expand Down

0 comments on commit dd62291

Please sign in to comment.