From 87c02f88d7d568b8233f2a9a3a8f4c1a423772ae Mon Sep 17 00:00:00 2001 From: Call White Date: Sat, 1 Apr 2023 22:39:26 +0800 Subject: [PATCH] Fix: Chinese input method "Enter" issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 中文输入法里打英文,直接按下Enter会直接发送出去,修复这个错误。 但如果[通过 `e.isComposing` 去判断](https://github.com/Yidadaa/ChatGPT-Next-Web/pull/328/files),在 Safari 上并不兼容,因此直接全局阻止在中文输入法状态下的 Enter 的事件就可以了。 这样做没有任何副作用,因为无论是什么输入法,在输入状态 Enter 本来就不应与页面发生交互。 参考在另一个 ChatGPT 项目 :https://github.com/lencx/ChatGPT/issues/369#issuecomment-1429313208 --- app/components/home.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/components/home.tsx b/app/components/home.tsx index de93510db..d909a346d 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -340,6 +340,15 @@ export function Chat(props: { } }, 500); }); + + // Fix Chinese input method "Enter" issue + document.addEventListener( + "keydown", + (e) => { + if (e.keyCode == 229) e.stopPropagation(); + }, + true, + ); return (