[object Object]

← back to Exo

fix: prevent form submission during IME composition (#1069)

844bcc7ce67a02b96b5cd57f89b016296b703b4b · 2026-01-01 01:11:04 +0800 · RickyChen / 陳昭儒

## Problem
When typing in Chinese (or other IME-based languages like
Japanese/Korean), pressing Enter to select a character from the IME
candidate list would incorrectly submit the message instead of
confirming the character selection.

## Solution
Added IME composition state detection in the `handleKeydown` function in
`ChatForm.svelte`:
- Check `event.isComposing` to detect active IME composition
- Fallback to `event.keyCode === 229` for broader browser compatibility
- Return early when IME is active, allowing normal character selection

## Changes
- Modified `dashboard/src/lib/components/ChatForm.svelte` 
- Added IME composition check before Enter key handling

Co-authored-by: Ricky Chen <rickychen@Rickys-MacBook-Pro.local>

Files touched

Diff

commit 844bcc7ce67a02b96b5cd57f89b016296b703b4b
Author: RickyChen / 陳昭儒 <ricky.chen@infinirc.com>
Date:   Thu Jan 1 01:11:04 2026 +0800

    fix: prevent form submission during IME composition (#1069)
    
    ## Problem
    When typing in Chinese (or other IME-based languages like
    Japanese/Korean), pressing Enter to select a character from the IME
    candidate list would incorrectly submit the message instead of
    confirming the character selection.
    
    ## Solution
    Added IME composition state detection in the `handleKeydown` function in
    `ChatForm.svelte`:
    - Check `event.isComposing` to detect active IME composition
    - Fallback to `event.keyCode === 229` for broader browser compatibility
    - Return early when IME is active, allowing normal character selection
    
    ## Changes
    - Modified `dashboard/src/lib/components/ChatForm.svelte`
    - Added IME composition check before Enter key handling
    
    Co-authored-by: Ricky Chen <rickychen@Rickys-MacBook-Pro.local>
---
 dashboard/src/lib/components/ChatForm.svelte | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/dashboard/src/lib/components/ChatForm.svelte b/dashboard/src/lib/components/ChatForm.svelte
index 95d023c3..3f622602 100644
--- a/dashboard/src/lib/components/ChatForm.svelte
+++ b/dashboard/src/lib/components/ChatForm.svelte
@@ -139,6 +139,11 @@
 	}
 
 	function handleKeydown(event: KeyboardEvent) {
+		// Prevent form submission during IME composition (e.g., Chinese, Japanese, Korean input)
+		if (event.isComposing || event.keyCode === 229) {
+			return;
+		}
+		
 		if (event.key === 'Enter' && !event.shiftKey) {
 			event.preventDefault();
 			handleSubmit();

← c1be5184 Fix tests broken by 283c (#1063)  ·  back to Exo  ·  Task Deduplication (#1062) 17f9b583 →