Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ButtonUnstyled] Fix keyboard navigation on customized elements #32204

Merged
merged 5 commits into from
May 4, 2022

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Apr 8, 2022

Fixed the detection of native elements in useButton. It should be now possible to trigger click events on ButtonUnstyled, which root is a wrapped in a component.

Unfortunately, this is not unit-testable, as neither JSDOM, nor browsers trigger the click event when Enter or Space is pressed on a native button.

Also added a doc section about custom buttons not interacting with forms as their native counterparts.

Fixes #32193


The first commit contains the actual fix. The second is a cleanup of no longer needed component parameter from useButton (this makes it more in-line with other hooks that are not concerned about the component or components).

@michaldudak michaldudak added component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Apr 8, 2022
@michaldudak michaldudak requested a review from a team April 8, 2022 17:04
@mui-bot
Copy link

mui-bot commented Apr 8, 2022

Details of bundle changes

@material-ui/core: parsed: +Infinity% , gzip: +Infinity%
@material-ui/lab: parsed: +Infinity% , gzip: +Infinity%
@material-ui/styles: parsed: +Infinity% , gzip: +Infinity%
@material-ui/private-theming: parsed: +Infinity% , gzip: +Infinity%
@material-ui/system: parsed: +Infinity% , gzip: +Infinity%
@material-ui/unstyled: parsed: +Infinity% , gzip: +Infinity%
@material-ui/utils: parsed: +Infinity% , gzip: +Infinity%
@mui/material-next: parsed: +Infinity% , gzip: +Infinity%
@mui/joy: parsed: +Infinity% , gzip: +Infinity%

Generated by 🚫 dangerJS against 502706a

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 11, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 11, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 25, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 26, 2022
michaldudak and others added 2 commits April 27, 2022 13:18
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Looks good, I could validate that it works in https://codesandbox.io/s/mui-emotion-submit-reset-button-bug-forked-19l1h9?file=/src/App.js

In cases where we can't cover some fix with test, it is nice to have a codesandbox built with the PR packages to showcase that it works :)

@michaldudak michaldudak merged commit 5ee5ba0 into mui:master May 4, 2022
@michaldudak michaldudak deleted the unstyled-button-click branch May 4, 2022 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ButtonUnstyled] It does not handle "space" and "enter" hit properly inside form element when customized
4 participants