Skip to content

[number field] Fix click handlers on ScrubArea#3827

Merged
mj12albert merged 4 commits intomui:masterfrom
mj12albert:fix/scrub-area-onclick
Jan 29, 2026
Merged

[number field] Fix click handlers on ScrubArea#3827
mj12albert merged 4 commits intomui:masterfrom
mj12albert:fix/scrub-area-onclick

Conversation

@mj12albert
Copy link
Copy Markdown
Member

@mj12albert mj12albert commented Jan 22, 2026

@mj12albert mj12albert added component: number field Changes related to the number field component. type: bug It doesn't behave as expected. labels Jan 22, 2026
@mj12albert mj12albert force-pushed the fix/scrub-area-onclick branch from c13ea0b to a433fdc Compare January 22, 2026 15:51
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 22, 2026

commit: 0072d02

@mui-bot
Copy link
Copy Markdown

mui-bot commented Jan 22, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+227B(+0.05%) 🔺+54B(+0.04%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 22, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit c13ea0b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6972477dbd7c4f0008a31060
😎 Deploy Preview https://deploy-preview-3827--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mj12albert mj12albert force-pushed the fix/scrub-area-onclick branch from a433fdc to e352308 Compare January 22, 2026 15:54
@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 22, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit a433fdc
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69724796b1344e0008b386bd
😎 Deploy Preview https://deploy-preview-3827--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 22, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 0072d02
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/697afc349a17850008233f0f
😎 Deploy Preview https://deploy-preview-3827--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mj12albert mj12albert marked this pull request as ready for review January 22, 2026 16:00
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jan 22, 2026

Greptile Summary

Fixes onClick handlers on NumberFieldScrubArea and its children by manually dispatching click events when pointer movement doesn't occur. The fix addresses issue #2761 where event.preventDefault() on pointerdown was preventing browser click events.

  • Tracks pointer movement with didMoveRef to distinguish clicks from scrubs
  • Stores original target with pointerDownTargetRef to dispatch click to correct element
  • Manually dispatches synthetic click event when pointer up occurs without movement
  • Adds test coverage for both direct clicks and clicks on child elements

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean and follows standard patterns for handling prevented default behavior. The fix properly tracks state with refs, correctly dispatches synthetic events, and includes comprehensive test coverage for both the direct and child element click scenarios.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/number-field/scrub-area/NumberFieldScrubArea.tsx Added click event restoration by tracking pointer movement and manually dispatching clicks when no scrubbing occurs
packages/react/src/number-field/scrub-area/NumberFieldScrubArea.test.tsx Added comprehensive test coverage for onClick handlers on ScrubArea and child elements

@mj12albert mj12albert requested a review from LukasTy January 23, 2026 15:10
@mj12albert mj12albert force-pushed the fix/scrub-area-onclick branch from e352308 to 5fc9e65 Compare January 26, 2026 09:43
</NumberField.Root>,
);

fireEvent.click(screen.getByTestId('scrub-area'));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to call userEvent.click to simulate all the events associated with a click to make it more life-like.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated~

@mj12albert mj12albert merged commit f7b67b2 into mui:master Jan 29, 2026
23 checks passed
@mj12albert mj12albert deleted the fix/scrub-area-onclick branch January 29, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: number field Changes related to the number field component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[number field] onClick doesn't fire on ScrubArea

3 participants