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.

Button should add role="button" when href prop is set (link button)

See original GitHub issue
  • 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 😯

The following jsx results in an <a> tag that does not have role="button" <Button href={url} target="_blank"> click here </Button>

Expected Behavior 🤔

The link button should have role="button" for accessability

Steps to Reproduce 🕹

Tech Version
Material-UI v4.10.1
React 16.13.1
Browser all

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
eps1loncommented, Jun 17, 2020

The link button should have role=“button” for accessability

Why? What you’re claiming is that <a href="example.com" target="_blank" /> is a button not a hyperlink. It triggers navigation therefore it’s an hyperlink.

Could you explain your rationale?

0reactions
eps1loncommented, Jun 17, 2020

The reason is that the coder chose to use a Materual UI <Button> component. She wants this element to look, feel and behave like a button. If she wanted the look, feel and behavior of a traditional hyperlink, she would have chosen to use plain old tag.

Why did they pass an href then? This seems like an exotic use case that we can’t audit completely.

It would also be a breaking change. I’m closing this issue until more information is provided. In the meantime: <Button href="example.com" target="_blank" role="button" /> is still possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Button should add role="button" when href prop is set (link ...
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >
ARIA: button role - Accessibility - MDN Web Docs
The button role is for clickable elements that trigger a response when activated by the user. Adding role="button" tells the screen reader ...
Read more >
Wrapping a react-router Link in an html button - Stack Overflow
I was wondering if there is a way to wrap a Link element from 'react-router' in an HTML button tag using react. I...
Read more >
Accessible links and buttons with React - Kitty Giraudel
This implies that a lot of links should become buttons when JavaScript is enabled and running. To avoid authoring ternaries all over the...
Read more >
How to Use a Button as a Link in React - Coding Beauty
Use Material UI button as link​​ When using Material UI, we can specify a link for the Button component using the href prop....
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