question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ButtonBase] Incorrectly adds role='button' when using a custom component and passing an href prop

See original GitHub issue

When using a material-ui button it adds role='button' when using a custom component prop even when passing an href prop.

I believe that this line in ButtonBase.js is the culprit. Perhaps it should be an && instead of ||

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Material-Ui ButtonBase.js applies role='button' attribute to the button when using a custom component even when passing an href prop

Expected Behavior 🤔

when using a custom component and passing an href prop to a button it should not have role='button' applied

Steps to Reproduce 🕹

See repro here: https://codesandbox.io/s/green-sun-vduiu?file=/src/Demo.tsx

Steps:

  1. inspect button and see it has role='button' on it

Context 🔦

Trying to create proper accessibility for links that look like buttons in a Gatsby.js site.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mnajdovacommented, May 12, 2021

Let’s discuss this in a PR with a concrete implementation and test. Manually going through implementation is not viable.

Sounds good. @Gautam-Arora24 you may start working on this if you want 😃

1reaction
eps1loncommented, May 12, 2021

Let’s discuss this in a PR with a concrete implementation and test. Manually going through implementation is not viable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[ButtonBase] Incorrectly adds role='button' when using a ...
When using a material-ui button it adds role='button' when using a custom component prop even when passing an href prop.
Read more >
Material UI - The `component` prop provided to ButtonBase is ...
(3) Material-UI: The component prop provided to ButtonBase is invalid. Please make sure the children prop is rendered in this custom component.
Read more >
Strict Mode - React
When strict mode is enabled, React compiles a list of all class components using the unsafe lifecycles, and logs a warning message with...
Read more >
Global Styling with Material-UI Theme Overrides and Props
Learn how to use global CSS overrides and default props in a theme to customize all instances of a Material-UI component in a...
Read more >
Warning: Each Child in a List Should Have a Unique 'key' Prop
It is not recommended to use the index of the array as the key prop if ... Then React will get confused and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found