fix(frontend): prevent submit during IME composition (#1562)

This commit is contained in:
Sleepy Ranx 🌙
2026-03-29 22:36:38 +08:00
committed by GitHub
parent d475de7997
commit 866cf4ef73
4 changed files with 17 additions and 3 deletions
@@ -34,6 +34,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { isIMEComposing } from "@/lib/ime";
import { cn } from "@/lib/utils";
import type { ChatStatus, FileUIPart } from "ai";
import {
@@ -833,7 +834,7 @@ export const PromptInputTextarea = ({
const handleKeyDown: KeyboardEventHandler<HTMLTextAreaElement> = (e) => {
if (e.key === "Enter") {
if (isComposing || e.nativeEvent.isComposing) {
if (isIMEComposing(e, isComposing)) {
return;
}
if (e.shiftKey) {
@@ -56,6 +56,7 @@ import {
import type { AgentThread, AgentThreadState } from "@/core/threads/types";
import { pathOfThread, titleOfThread } from "@/core/threads/utils";
import { env } from "@/env";
import { isIMEComposing } from "@/lib/ime";
export function RecentChatList() {
const { t } = useI18n();
@@ -271,7 +272,8 @@ export function RecentChatList() {
onChange={(e) => setRenameValue(e.target.value)}
placeholder={t.common.rename}
onKeyDown={(e) => {
if (e.key === "Enter") {
if (e.key === "Enter" && !isIMEComposing(e)) {
e.preventDefault();
handleRenameSubmit();
}
}}