fix: IME 判断增加 keyCode !== 229
Project CI / Repository checks (pull_request) Failing after 10s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 1m40s
Project CI / Native shell tests (pull_request) Successful in 2m12s

This commit is contained in:
2026-07-28 12:05:45 +08:00
parent 7902832edb
commit e145d031c0
3 changed files with 14 additions and 4 deletions
@@ -105,7 +105,7 @@ describe('EditorAgentDraftTextarea', () => {
expect(disconnect).toHaveBeenCalledTimes(1);
});
it('submits on Enter and keeps Shift+Enter for line breaks', () => {
it('submits on Enter and keeps line breaks or IME confirmation from submitting', () => {
const onSubmit = vi.fn((event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
});
@@ -119,6 +119,13 @@ describe('EditorAgentDraftTextarea', () => {
fireEvent.keyDown(input, { key: 'Enter', shiftKey: true });
expect(onSubmit).not.toHaveBeenCalled();
fireEvent.keyDown(input, {
key: 'Enter',
isComposing: false,
keyCode: 229,
});
expect(onSubmit).not.toHaveBeenCalled();
fireEvent.keyDown(input, { key: 'Enter' });
expect(onSubmit).toHaveBeenCalledTimes(1);
});
@@ -87,9 +87,11 @@ export function EditorAgentDraftTextarea({
}, []);
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
if (event.key === 'Enter'
&& !event.shiftKey
&& !event.nativeEvent.isComposing
if (
event.key === 'Enter' &&
!event.shiftKey &&
!event.nativeEvent.isComposing &&
event.nativeEvent.keyCode !== 229
) {
event.preventDefault();
event.currentTarget.form?.requestSubmit();