fix: Input IME enter to complete composition bug#4338
fix: Input IME enter to complete composition bug#4338alexisareyn wants to merge 2 commits intocloudscape-design:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4338 +/- ##
==========================================
- Coverage 97.45% 97.44% -0.01%
==========================================
Files 902 902
Lines 26468 26474 +6
Branches 9540 9542 +2
==========================================
+ Hits 25794 25798 +4
- Misses 631 633 +2
Partials 43 43 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Update:
|
Fix race condition where compositionend fires before onKeyDown handler, causing premature search submission when users press Enter to complete character composition.
fa81bbc to
16ac3dc
Compare
georgylobko
left a comment
There was a problem hiding this comment.
-
Got it, so I assume
pages/input/korean-ime.page.tsxisn't needed then? -
No, this is a new one, and from what I can see, the tests are passing in the pipeline
-
No worries, we don't run certain workflows for external contributions
Fix race condition where compositionend fires before onKeyDown handler, causing premature search submission when users press Enter to complete character composition.
This was resolved for the Autosuggest component in : #4182
Description
This PR fixes a critical accessibility issue affecting Korean (and other IME) users where pressing Enter to complete character composition would accidentally trigger search submission instead of just completing the character.
Problem: When Korean users type characters like 가 (ga), pressing Enter to complete the character would incorrectly trigger search submission because the browser's
compositionendevent fires before theonKeyDownhandler executes, creating a race condition.Root Cause: The timing issue meant there was no reliable way to distinguish between "Enter pressed to complete character composition" vs "Enter pressed to trigger search".
Solution: Created a useIMEComposition hook that tracks composition state and uses requestAnimationFrame to maintain the composition flag briefly after compositionend, allowing the onKeyDown handler to correctly identify composition-related Enter keypresses and prevent inappropriate search triggering.
How has this been tested?
Automated Testing:
useIMECompositionhook covering character formation, multiple composition cycles, edge cases, and proper cleanupnpm testManual Testing:
Start the dev server:
npm startNavigate to the autosuggest search page at http://localhost:8080
Switch to Korean 2-set keyboard input method
Type Korean characters (e.g., ㄱ + ㅏ to form 가) and press Enter to complete - should NOT trigger search
Type regular text and press Enter - should trigger search normally
Run automated tests:
npm testReview checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.