Conversation
The combobox trigger opened the list from pointerdown for every pointer type, so a finger that landed on it while scrolling a form opened the list under it. It now mirrors the select trigger: touch down does nothing, and pointerup — which a scroll never delivers, the browser cancels the pointer instead — opens on the tap. Mouse still opens on press.
Contributor
Author
|
Run evidence (macOS, chromium + webkit via New tests against unpatched main (chromium,
Branch: combobox, chromium + webkit —
svelte-check —
|
🦋 Changeset detectedLatest commit: e1c6f61 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
|
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.
The problem
Combobox.Triggertoggles the list frompointerdownfor every pointer type:On a touch device
pointerdownfires the moment a finger lands, before the browser knows whether this is a tap or the start of a scroll. A finger that lands on the trigger while scrolling a form opens the list under it (and focuses the input). Scroll a page with a few comboboxes on a phone and they pop open as you go.Select.Triggeralready handles this — it bails on touch inonpointerdown("prevent opening on touch down which can be triggered when scrolling on touch devices") and opens fromonpointerup, which native panning does not deliver: once the browser takes the gesture as a scroll it firespointercancelinstead.The fix
SelectComboTriggerStatetakes the same touch timing as the select trigger:pointerdownstill prevents default for every pointer (that is what keeps focus on the input instead of the button) and still toggles for mouse and pen; for touch it returns, and a newonpointeruptoggles on the tap. The focus-then-toggle body is shared by the keyboard, pointerdown and pointerup paths.This aligns the touch timing only. The select trigger's other handler details (mouse-button / ctrl filtering, explicit capture release) belong to its own focus model and are not copied; the combobox's mouse, pen and input-focus behaviour is unchanged.
Tests
Two tests in
combobox.browser.test.ts, under a newTouchblock, driving the trigger withPointerEvents ofpointerType: "touch":should not open the trigger on touch down, which also fires when a scroll starts on it— afterpointerdownthe list is closed andopenis false; after thepointercancela scroll produces, still closed.should open the trigger on a tap— closed afterpointerdown, open with the input focused afterpointerup.Both assert the state after down and before cancel/up — closed, and the input not focused — so an implementation that opens or focuses on down and undoes it on cancel cannot pass. Both fail on unpatched
main(the list is open after the pointerdown).pnpm -F tests test:browser --run src/tests/comboboxpasses on chromium and webkit (134 tests). Synthetic events: they pin the handler timing, not native panning or the software keyboard.