Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#333 from qirong77/main
Browse files Browse the repository at this point in the history
fix:修复中文输入法下enter错误发送消息问题
  • Loading branch information
Yidadaa authored Apr 2, 2023
2 parents 44145f1 + 00a2822 commit d54c983
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ function useSubmitHandler() {
const config = useChatStore((state) => state.config);
const submitKey = config.submitKey;

const shouldSubmit = (e: KeyboardEvent) => {
const shouldSubmit = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key !== "Enter") return false;

if(e.key==='Enter' && e.nativeEvent.isComposing) return false
return (
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
Expand Down Expand Up @@ -256,7 +256,7 @@ export function Chat(props: {
};

// check if should send message
const onInputKeyDown = (e: KeyboardEvent) => {
const onInputKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (shouldSubmit(e)) {
onUserSubmit();
e.preventDefault();
Expand Down Expand Up @@ -488,7 +488,7 @@ export function Chat(props: {
rows={4}
onInput={(e) => onInput(e.currentTarget.value)}
value={userInput}
onKeyDown={(e) => onInputKeyDown(e as any)}
onKeyDown={onInputKeyDown}
onFocus={() => setAutoScroll(true)}
onBlur={() => {
setAutoScroll(false);
Expand Down

0 comments on commit d54c983

Please sign in to comment.