-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Don't set redundant role=button #28488
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Maybe we should in addition add test that actually tests what the PR title describes (using a component that renders button
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to not depend on the JS runtime to set the correct attributes? The issue seems to be still here https://validator.w3.org/nu/?doc=https%3A%2F%2Fdeploy-preview-28488--material-ui.netlify.app%2Fcomponents%2Fbuttons%2F
(Maybe it's only the demo that needs to be fixed)
Right, the issue still occurs when rendering on the server. I'll see what I can do about it. |
After some investigation, I must say I'm not aware of any way to figure out the type of the rendered host component on the server. I propose we postpone adding accessibility attributes to the client-side rendering phase. This means native This solution is IMO still better than what we have in Material Button, or how, for example, react-aria works. In both cases providing a component that renders a button does result in a redundant |
This issue makes me think of https://mui.com/guides/routing/#button When we can't see through the custom component provided, we assume that it needs the role, and if it doesn't, we ask developers to ignore the role: You can blame to retrieve the initial PR/issue behind it. I would encourage we revert this PR, and instead focus on only fixing the docs. From what I understand:
For instance: https://codesandbox.io/s/22igz?file=/demo.tsx, it's not rendering a span, even if had provided |
Thanks for the feedback. I decided to merge it as there was no response for a week.
Yes, that's correct.
Thanks, I'll dig into this more. I've watched parts of the video and it seems to me that server-side rendering would not apply to buttons, as it's designed for non-interactive elements (i.e. ones that don't use
Yes, the behavior changed, but working on unstyled components gives us the opportunity to introduce improvements. Now, what is or isn't an improvement is of course a matter of discussion. The "give us any component you want and we'll add proper attributes when necessary so you don't have to think about it" promise would sound pretty appealing to me if I was using the library.
In this case, I could have used Do you see the |
Fixes the problem seen in #28429 (comment)
Preview: https://deploy-preview-28488--material-ui.netlify.app/components/buttons/