Skip to content

[checkbox][radio][switch] Preserve modifier key properties in the change event - #3935

Merged
mj12albert merged 3 commits into
mui:masterfrom
mj12albert:fix/button-control-modifier-keys
Feb 6, 2026
Merged

mj12albert merged 3 commits into
mui:masterfrom
mj12albert:fix/button-control-modifier-keys

Conversation

@mj12albert

Copy link
Copy Markdown
Member

Fixes #3875

@mj12albert mj12albert added component: switch Changes related to the switch component. component: checkbox Changes related to the checkbox component. labels Feb 2, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 2, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@3935
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3935
    

commit: e7c6df6

@mui-bot

mui-bot commented Feb 2, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+357B(+0.08%) 🔺+151B(+0.11%)

Details of bundle changes


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

@mj12albert
mj12albert force-pushed the fix/button-control-modifier-keys branch from 5f8a7e4 to f1c9fa7 Compare February 2, 2026 11:39
@netlify

netlify Bot commented Feb 2, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 5f8a7e4
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69808c7c4f60c70008db96bf
😎 Deploy Preview https://deploy-preview-3935--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

netlify Bot commented Feb 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit e7c6df6
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6985def6fc942f0007e1c173
😎 Deploy Preview https://deploy-preview-3935--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.

@LukasTy LukasTy left a comment

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.

LGTM. 👍
Could it also be relevant for the Radio component? 🤔

@mj12albert mj12albert changed the title [checkbox][switch] Preserve modifier key properties in the change event [checkbox][radio][switch] Preserve modifier key properties in the change event Feb 2, 2026
@mj12albert mj12albert added the component: radio group Changes related to the radio group component. label Feb 2, 2026
@mj12albert
mj12albert marked this pull request as ready for review February 2, 2026 13:28
@greptile-apps

greptile-apps Bot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Preserves keyboard modifier key properties (shift, ctrl, alt, meta) in change events for checkbox, radio, and switch components by replacing inputRef.current?.click() with inputRef.current?.dispatchEvent(new PointerEvent('click', {...})).

  • Modified the onClick handlers in CheckboxRoot.tsx, RadioRoot.tsx, and SwitchRoot.tsx to dispatch synthetic PointerEvent instances with modifier key properties
  • Added comprehensive tests for all three components to verify that modifier keys are correctly preserved and passed to the onCheckedChange / onValueChange callbacks
  • The synthetic event is configured with bubbles: true to match the behavior of native click events

Confidence Score: 5/5

  • This PR is safe to merge with no risks
  • The changes are well-isolated, correctly implemented, and thoroughly tested. The approach properly preserves modifier key properties without affecting existing functionality.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/checkbox/root/CheckboxRoot.tsx Replaced .click() with dispatchEvent(new PointerEvent()) to preserve modifier keys (shift, ctrl, alt, meta) in the change event
packages/react/src/radio/root/RadioRoot.tsx Replaced .click() with dispatchEvent(new PointerEvent()) to preserve modifier keys (shift, ctrl, alt, meta) in the change event
packages/react/src/switch/root/SwitchRoot.tsx Replaced .click() with dispatchEvent(new PointerEvent()) to preserve modifier keys (shift, ctrl, alt, meta) in the change event

@mj12albert
mj12albert merged commit cca68a5 into mui:master Feb 6, 2026
7 checks passed
@mj12albert
mj12albert deleted the fix/button-control-modifier-keys branch February 6, 2026 12:43
@cgatian

cgatian commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

@mj12albert thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: checkbox Changes related to the checkbox component. component: radio group Changes related to the radio group component. component: switch Changes related to the switch component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[checkbox] event.shiftkey always false

5 participants