From ccf5fef34d03fd68df3f728e6cdd1610f66b9aa3 Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Sat, 17 Aug 2024 23:32:13 -0700 Subject: [PATCH] fix: add IME composition event handling to ComposerInput (#677) --- .changeset/tame-garlics-help.md | 5 +++++ packages/react/src/primitives/composer/ComposerInput.tsx | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/tame-garlics-help.md diff --git a/.changeset/tame-garlics-help.md b/.changeset/tame-garlics-help.md new file mode 100644 index 000000000..faabcd2f6 --- /dev/null +++ b/.changeset/tame-garlics-help.md @@ -0,0 +1,5 @@ +--- +"@assistant-ui/react": patch +--- + +fix: do not capture enter key during IME composition events diff --git a/packages/react/src/primitives/composer/ComposerInput.tsx b/packages/react/src/primitives/composer/ComposerInput.tsx index bf6e1234b..9733310ef 100644 --- a/packages/react/src/primitives/composer/ComposerInput.tsx +++ b/packages/react/src/primitives/composer/ComposerInput.tsx @@ -62,6 +62,9 @@ export const ComposerPrimitiveInput = forwardRef< const handleKeyPress = (e: KeyboardEvent) => { if (isDisabled) return; + // ignore IME composition events + if (e.nativeEvent.isComposing) return; + if (e.key === "Enter" && e.shiftKey === false) { const { isRunning } = useThread.getState();