Skip to content

[button] Fix custom keyboard click dispatch#4838

Draft
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:codex/fix-button-custom-keyboard-click
Draft

[button] Fix custom keyboard click dispatch#4838
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:codex/fix-button-custom-keyboard-click

Conversation

@atomiks
Copy link
Copy Markdown
Contributor

@atomiks atomiks commented May 18, 2026

Custom-tag Buttons handled keyboard activation by directly calling the Button prop handler. This makes Enter and Space dispatch a real click instead, so render-element and delegated click handlers run through the normal event path.

Root cause

For non-native buttons, useButton called the captured onClick prop directly:

externalOnClick?.(event);

That skipped other click handlers on the rendered element, including cases like:

<Button nativeButton={false} render={<span onClick={handleClick} />} />

Changes

  • Dispatch a real click for Enter and Space activation on non-native, non-composite buttons.
  • Add missing public Button coverage around the affected keyboard path and nearby documented behavior: form submission, disabled state callbacks, and focusable disabled transitions.
  • Keep the fix narrow and avoid broader render-prop disabled guard machinery for rare handler placement on disabled render elements.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 18, 2026

commit: 5530a85

@atomiks atomiks added component: button Changes related to the button component. type: bug It doesn't behave as expected. labels May 18, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 18, 2026

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+74B(+0.02%) 🔺+14B(+0.01%)

Details of bundle changes

Performance

Total duration: 1,103.85 ms -116.18 ms(-9.5%) | Renders: 50 (+0) | Paint: 1,694.30 ms -191.24 ms(-10.1%)

No significant changes — details


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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 5530a85
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a0ad36249082d000781daba
😎 Deploy Preview https://deploy-preview-4838--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant