Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

๐Ÿ› Fixed search navigating away during CJK IME composition

Open davehuang-tw opened this issue 8 months ago โ€ข 3 comments

When using CJK input methods (Chinese, Japanese, Korean) in the sodo-search modal (Cmd+K), pressing Enter to confirm a character during IME composition incorrectly triggers navigation to the first search result. This makes search unusable for CJK users.

The keyboard handler in the Results component used keyup, but compositionend fires before keyup, so event.isComposing is already false by then. Switched to keydown where isComposing reliably reflects the composition state.

Demo

Before (main branch)

https://github.com/user-attachments/assets/248f9403-d896-4cdc-ac5b-6105379a9a42

  • Type "ๆธฌ่ฉฆ" using zh-Hant IME while characters are still being composed
  • Press Enter to confirm composition
  • The search immediately redirects to the 1st result instead of finalizing the composed text and letting the user select their intented result

After (PR branch)

https://github.com/user-attachments/assets/d1f9e041-1e86-4549-a95b-7ece822e207b

  • Type "ๆธฌ่ฉฆ" using zh-Hant IME while characters are still being composed
  • Press Enter to confirm composition
  • Search results remain, letting user manually pick search item

[!NOTE] Low Risk Low risk: small change to keyboard event handling in the search results list; main risk is unintended key handling differences between keyup and keydown for navigation/Enter behavior.

Overview Fixes Cmd+K search result navigation for CJK IME users by moving the results keyboard listener from keyup to keydown and ignoring events during composition (event.isComposing / legacy keyCode === 229).

This prevents Enter presses used to confirm IME text from triggering immediate navigation to the currently selected search result.

Written by Cursor Bugbot for commit 866ececceb6a4ce4b43c8b6a98f4b96c2743bd3a. This will update automatically on new commits. Configure here.

davehuang-tw avatar Mar 18 '26 16:03 davehuang-tw

No actionable comments were generated in the recent review. ๐ŸŽ‰

โ„น๏ธ Recent review info
โš™๏ธ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ee46ddfb-6beb-4b57-a532-de8fddf443be

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 9f012d545af53bf925c0a5258e1269e7df53e83b and 8ac25313e1a4dcb2972e9fd7f75505838e1ffbaa.

๐Ÿ“’ Files selected for processing (1)
  • apps/sodo-search/src/components/popup-modal.js
๐Ÿšง Files skipped from review as they are similar to previous changes (1)
  • apps/sodo-search/src/components/popup-modal.js

Walkthrough

The change updates keyboard handling in the popup modal component: the handler was renamed from keyUphandler to keyDownHandler, keyup listeners were replaced with keydown listeners, and the handler now ignores IME composition when event.isComposing is true or event.keyCode === 229. The effect captures containerRef?.current?.ownerDocument into a local doc variable and adds/removes the keydown listener on that doc (cleanup removes keyDownHandler). Existing arrow/enter navigation logic is preserved.

๐Ÿšฅ Pre-merge checks | โœ… 2 | โŒ 1

โŒ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
โœ… Passed checks (2 passed)
Check name Status Explanation
Title check โœ… Passed The title clearly summarizes the main change: fixing a bug where CJK IME composition interferes with search navigation.
Description check โœ… Passed The description is well-related to the changeset, explaining the issue, root cause, solution, and providing before/after demos of the fix.

โœ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.

โœจ Finishing Touches
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
๐Ÿ“ Coding Plan
  • [ ] Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Mar 18 '26 16:03 coderabbitai[bot]

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

cursor[bot] avatar Mar 18 '26 17:03 cursor[bot]