Repository navigation
[number field] Fire ScrubArea onClick once per click - #5889
Merged
michaldudak merged 1 commit intoOct 6, 2026
Merged
michaldudak merged 1 commit into
michaldudak merged 1 commit into
Conversation
The scrub area synthesizes a click on pointerup when the pointer didn't move, assuming that preventDefault on pointerdown suppresses the browser's click. It doesn't. With pointer lock the native click targets the lock element, but without it (WebKit never requests the lock, and requests can be denied) the native click reaches the scrub area too, so onClick fired twice. Defer the synthesized click by one task and skip it when a native click already reached the scrub area.
commit: |
Bundle size
PerformanceTotal duration: 433.22 ms -16.25 ms(-3.6%) | Renders: 76 (+0) | Paint: 795.39 ms -26.05 ms(-3.2%) No significant changes — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
michaldudak
marked this pull request as ready for review
October 5, 2026 13:44
michaldudak
requested review from
atomiks,
colmtuite,
flaviendelangle and
jjenzz
as code owners
October 5, 2026 13:44
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.
Clicking
NumberField.ScrubAreawithout dragging can call itsonClicktwice.On pointerup with no movement, the scrub area dispatches a synthetic
click, because its comment assumes thatpreventDefault()onpointerdownsuppresses the browser's click. It doesn't:preventDefault()onpointerdownonly suppresses the compatibility mouse events, notclick.<body>), so the synthetic click is the only one the scrub area sees. That case works today.onClickfires twice. That happens in WebKit, which never requests the lock, and whenever the lock request is denied (e.g. in an iframe withoutallow-pointer-lock).With real browser input in Chromium (pointer lock not granted in the test runner), one click produced two
onClickcalls.The fix records whether a native click reached the scrub area (
onClickCapture), and defers the synthetic click by one task. The browser dispatches its click in the same task aspointerup. The synthetic click is skipped when the native one already arrived. Firefox already defers the handler by 20 ms, so the same check applies there.Why the existing test didn't catch it
"should fire onClick when clicked without scrubbing" rendered no
NumberField.Input, so the scrub listener, and with it the click synthesis, never ran. The singleonClickcame from user-event's own click. The test now renders an input and uses real browser input (vitest/browser'suserEvent).Validation
NumberFieldScrubAreasuites pass in jsdom and twice in Chromium. ESLint and Prettier pass.<body>, so the synthetic click still fires once.Found during an audit of the test suite for tests that can't fail.