-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(button): remove role="button" from button styled anchors #5522
fix(button): remove role="button" from button styled anchors #5522
Conversation
Deploy preview for carbon-elements ready! Built with commit 3a3a336 |
Deploy preview for carbon-components-react ready! Built with commit 3a3a336 https://deploy-preview-5522--carbon-components-react.netlify.com |
A question; What happens if the button has non-text content? |
@asudoh Well, if there was no label whatsoever DAP would throw and error for an anchor tag not having an associated label. Is that a use case we support? For an icon I thought we set a label on the svg. |
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.
Looks good to me! Separately, I see that DAP is saying that p
and a
are form control elements, are they really? Or am I misunderstanding and it's just picking up the role='button'
?
@abbeyhrt right yeah! They become form control elements the moment we designate them |
Wow, definitely an awkward violation lol. Would you want to add a quick test to check for this too with any links to refer to why we need to do this? |
@joshblack added test! Though you'll notice we we had two nested divs inside our test button that I removed -- they didn't seem to be directly related to any of the tests I saw in that unit, but there might be something I'm missing. |
@dakahn You could detect if |
That's a great point ☝️, |
Hey @joshblack brought up a good point that it probably makes more sense to simply remove |
button
element buttons
@dakahn I'm not really sure how the non-button elements styled to look like buttons are used but is it a problem that they're no longer announced as buttons? |
@abbeyhrt my understanding is they are used when you are navigating to different parts of an app, so I think it would make more sense that they were not announced as buttons. I believe they are just styled like them since a lone link doesn't seem to have the same affordance/CTA as a button. |
@tw15egan Ah gotcha, makes sense! Thanks for explaining! |
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.
Makes sense to me, DAP errors have been eliminated ☠️
👍 ✅
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.
LGTM 👍 - Thanks @dakahn!
…design-system#5522) * fix(Dropdown): rely on list-box height closes carbon-design-system#4916 * fix(button): add aria label to non button element button * test(button): add a test checking that <a> button's get an aria-label * fix(button): undo previous changes; remove role=button for anchor * test(button): remove unneeded test for role Co-authored-by: TJ Egan <[email protected]> Co-authored-by: Josh Black <[email protected]>
Closes #5521
Closes #5112
Implicit labeling (having wrapped text in the sub-tree acting as the label) only works for native
button
elements.For instances where the button is an anchor tag, p tag or otherwise we need to specify the label with text matching the visible label.Changelog
New
added anaria-label: children
to theanchorProps
objectrole="button"
Testing / Reviewing
Since button is a widely used generic component I could totally be missing something/some use case. Otherwise just open up Chrome and run DAP with the latest ruleset and you should see zero errors reported 🏄