fix(Select): guard IME composition-commit Enter (keyCode 229)#2082
Closed
greymoth-jp wants to merge 1 commit into
Closed
fix(Select): guard IME composition-commit Enter (keyCode 229)#2082greymoth-jp wants to merge 1 commit into
greymoth-jp wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 00824a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Author
|
Closing this. It's a minor IME composition guard with failing checks I haven't resolved, so I'll take it off your queue. Thanks for the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SelectInputState.onkeydown(inselect.svelte.ts, shared by both theSelectandComboboxinputs) commits the highlighted item on Enter as long as the user is not composing:In Safari with a Japanese (or other CJK) IME, the Enter that commits the IME composition arrives with
isComposing === falseandkeyCode === 229. So!e.isComposingis true, the guard misses it, and the highlighted item gets selected (and the menu closes) while the user only meant to confirm what they typed.Commandalready guards against exactly this incommand.svelte.ts, with a comment explaining why:The select input handler was missing the
keyCode === 229half of that check, soSelect/ComboboxandCommandbehave differently for the same IME.Change
&& e.keyCode !== 229to the Enter guard inselect.svelte.ts, mirroringCommand.Comboboxregression test: with item 2 highlighted, an Enter delivered withkeyCode === 229leaves the menu open and selects nothing, while a normal Enter still commits the selection.The fix lives in
SelectInputState, which is also used bycombobox-input.svelte, so this covers both components.Verification
I traced the keydown path to confirm the fix: without it, the
keyCode === 229Enter passes the old guard and reachestoggleItem+handleClose; with it, the Enter branch is skipped and the event falls through to theINTERACTION_KEYSearly return, so the menu stays open and nothing is selected. A plain Enter (keyCode 13) still selects, which the existing "select item with the enter key" test covers.I was not able to run the browser test suite locally (the
pnpmpostinstall scripts fail on my Windows setup and the runner needs a downloaded browser), so the new test is unrun here. It follows the existingdispatchEventidiom used in the accordion tests and the Enter/highlight assertions from the existing combobox test, so CI should exercise it. Happy to adjust the test or its placement.