Repository navigation
Conversation
5760c2f to
99efccb
Compare
llastflowers
left a comment
There was a problem hiding this comment.
Thanks for working on this fix! Before we can merge this we need to:
- Preserve
option.click()with a guardedclicklistener (as mentioned in PR description) - Add a direct
option.click()regression test - Remove the new direct
fireCommitEvent(target)call from the keyboard path: Lettarget.click()reach theclicklistener as it previously did, preserving the existing event order anddetail.eventvalue - Ensure the guard resets when a
mousedownis not followed by a click
mousedown commits the option; the click that follows is skipped so one mouse selection fires one combobox-commit. A click with no preceding mousedown, such as option.click(), still commits, which is also how Enter and Tab commit again. The guard holds the committed option and is cleared by the next click anywhere in the document, so a mousedown the pointer never completed cannot swallow a later click.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Stale mouse-down state can suppress a later legitimate keyboard or programmatic commit.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds mousedown-based option commits so input blur does not suppress mouse selection.
Changes:
- Commits primary-button selections on
mousedown. - Prevents the following click from duplicating the commit.
- Adds regression tests and updates event documentation.
| File | Description |
|---|---|
src/index.ts |
Adds mouse-down commit handling and click deduplication. |
test/test.js |
Tests mouse, direct-click, and blur behavior. |
README.md |
Documents mouse-down event timing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } else if (committedOnMousedown === target) { | ||
| committedOnMousedown = null | ||
| return |
There was a problem hiding this comment.
Hi @cpruijsen!
Thanks for taking the time! I just checked copilot’s comment and looks like we have a remaining edge case from @llastflowers's previous comment to reset the guard when a mousedown isn’t followed by its corresponding click

Summary
The list listens on
mousedownand onclick.mousedowncommits, and the click that follows it is skipped, so one mouse selection fires onecombobox-commitand ablurhandler that callsstop()no longer loses it (mousedownruns beforeblur;stop()removed the oldclicklistener). A click with no precedingmousedown, such asoption.click(), still commits, so the keyboard path is unchanged:commit()callstarget.click()and the click listener fires the event with the click indetail.event. Non-primary buttons are ignored, matchingclick.The guard holds the option the
mousedowncommitted and is cleared by the next click anywhere in the document, so a press the pointer never completed cannot swallow a later click on that option.For a mouse selection
detail.eventis now themousedownevent rather than theclick. That follows from committing onmousedown.Fixes #54.
Decision
The library listens on
mousedown(the approach in #54) rather than leaving commit onclickand adding aninteractingWithListflag in the example, as github/auto-complete-element and github/text-expander-element do for this race. Closing the list on input blur is normal. Binding commit toclickalone makes every such consumer lose the mouse path; the demo was the reproduction.Test plan
mousedown->blur/stop()->clickstill fires onecombobox-commit.option.click()fires onecombobox-commit.mousedownwhose click lands elsewhere does not suppress a lateroption.click().click-only listener; passes withmousedownplus the guardedclick.<a>options updatinglocation.hash.npm test(eslint,tsc, Karma/Chrome Headless): 27 tests completed.