[ButtonBase] Ensure that onClick propagates when non-native button is clicked#47800
Merged
silviuaavram merged 5 commits intomui:masterfrom Feb 20, 2026
Merged
Conversation
1 task
Netlify deploy previewBundle size report
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes onClick event propagation for non-native ButtonBase components when activated via keyboard (Enter/Space keys). Previously, keyboard-triggered clicks on non-native buttons (e.g., component="div") would directly call the onClick handler without generating a proper click event, preventing the event from bubbling to parent elements.
Changes:
- Replaced direct onClick invocations with
event.currentTarget.click()to generate proper click events that bubble - Removed onClick existence checks to allow event propagation even when ButtonBase itself has no onClick handler
- Added comprehensive tests verifying click event propagation to parent elements for both Enter and Space key activation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/mui-material/src/ButtonBase/ButtonBase.js | Modified keyboard event handlers (Enter and Space) to call .click() instead of directly invoking onClick, enabling proper event bubbling for non-native buttons |
| packages/mui-material/src/ButtonBase/ButtonBase.test.js | Added two new tests verifying that click events propagate to parent elements when Enter or Space keys are pressed on non-native buttons |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3371089 to
57010de
Compare
siriwatknp
reviewed
Feb 20, 2026
siriwatknp
approved these changes
Feb 20, 2026
Member
siriwatknp
left a comment
There was a problem hiding this comment.
👍 small typo in the upgrading guide.
ae3a7e5 to
ffc9ed5
Compare
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.
It's essentially the fix from #30145 by @ kmurgic but with some changes:
clickevent on the buttonFixes #30144