feat: prevent form submission during IME composition in ChatInterface and ConfigDialog
This commit is contained in:
@@ -121,6 +121,9 @@ export const ChatInterface = React.memo<ChatInterfaceProps>(({ assistant }) => {
|
||||
const handleKeyDown = useCallback(
|
||||
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (submitDisabled) return;
|
||||
// Don't submit while an IME is composing (e.g. pressing Enter to pick a
|
||||
// Chinese/Japanese/Korean candidate must confirm text, not send).
|
||||
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
||||
if (e.key === "Enter" && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
handleSubmit();
|
||||
|
||||
@@ -96,7 +96,8 @@ export function ConfigDialog({
|
||||
if (error) setError(null);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") handleSave();
|
||||
if (e.key === "Enter" && !e.nativeEvent.isComposing)
|
||||
handleSave();
|
||||
}}
|
||||
aria-invalid={error ? true : undefined}
|
||||
aria-describedby={error ? "deploymentUrl-error" : undefined}
|
||||
|
||||
Reference in New Issue
Block a user