Skip to content

Commit

Permalink
Fix IME not working correctly in Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jan 25, 2024
1 parent 629c84d commit d9547c7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# [Unreleased]

- Fix IME not working correctly in Safari.

# 2.0.0-beta.1

- Fix syntax label from "Javascript" to "JavaScript".
Expand Down
7 changes: 6 additions & 1 deletion packages/quill/src/core/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ class Composition {

this.scroll.domNode.addEventListener('compositionend', (event) => {
if (this.isComposing) {
this.handleCompositionEnd(event);
// Webkit makes DOM changes after compositionend, so we use microtask to
// ensure the order.
// https://bugs.webkit.org/show_bug.cgi?id=31902
queueMicrotask(() => {
this.handleCompositionEnd(event);
});
}
});
}
Expand Down
13 changes: 13 additions & 0 deletions packages/quill/test/e2e/list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ test.describe('list', () => {
{ insert: '\n', attributes: { list } },
]);
});

test('typing in an empty editor with IME and press Backspace', async ({
page,
editorPage,
composition,
}) => {
await editorPage.setContents([{ insert: '\n' }]);

await editorPage.setSelection(9, 0);
await editorPage.typeWordWithIME(composition, '我');
await page.keyboard.press('Backspace');
expect(await editorPage.getContents()).toEqual([{ insert: '\n' }]);
});
});
}

Expand Down

0 comments on commit d9547c7

Please sign in to comment.