Merge pull request #1559 from yagitoshiro/fix/ime-enter-submit-chat

fix(web): don't submit chat on Enter during IME composition
This commit is contained in:
Rohan Verma 2026-06-29 17:47:04 -07:00 committed by GitHub
commit deec7f0d01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View file

@ -696,7 +696,9 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
onKeyDown?.(e); onKeyDown?.(e);
if (e.defaultPrevented) return; if (e.defaultPrevented) return;
if (e.key === "Enter" && !e.shiftKey) { // Ignore Enter while an IME composition is active (e.g. confirming a
// Japanese/Chinese/Korean conversion) so it doesn't submit the message.
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
e.preventDefault(); e.preventDefault();
onSubmit?.(); onSubmit?.();
return; return;

View file

@ -713,6 +713,10 @@ const Composer: FC = () => {
// Arrow / Enter / Escape navigation for the active picker. // Arrow / Enter / Escape navigation for the active picker.
const handleKeyDown = useCallback( const handleKeyDown = useCallback(
(e: React.KeyboardEvent) => { (e: React.KeyboardEvent) => {
// While an IME composition is active (e.g. confirming a Japanese/Chinese/
// Korean conversion), let the Enter/Arrow keys reach the IME instead of
// driving picker navigation/selection.
if (e.nativeEvent.isComposing) return;
if (showPromptPicker) { if (showPromptPicker) {
if (e.key === "ArrowDown") { if (e.key === "ArrowDown") {
e.preventDefault(); e.preventDefault();

View file

@ -99,7 +99,9 @@ export const FreeComposer: FC = () => {
gate("mention documents"); gate("mention documents");
return; return;
} }
if (e.key === "Enter" && !e.shiftKey) { // Ignore Enter while an IME composition is active (e.g. confirming a
// Japanese/Chinese/Korean conversion) so it doesn't submit the message.
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
e.preventDefault(); e.preventDefault();
if (text.trim()) { if (text.trim()) {
aui.composer().send(); aui.composer().send();