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

fix(Tabs): add ARIA attributes #4970

Merged
merged 8 commits into from
Jan 16, 2020
Merged

Conversation

asudoh
Copy link
Contributor

@asudoh asudoh commented Jan 8, 2020

This change adds ARIA attributes to <Tab> and <TabContent> to better describe their relationship.

Fixes #4968.

Changelog

New

  • aria-controls to <Tab>.
  • aria-labelledby to <TabContent>.

Testing / Reviewing

Testing should make sure React tabs component is not broken.

This change adds ARIA attributes to `<Tab>` and `<TabContent>` to
better describe their relationship.

Fixes carbon-design-system#4968.
@netlify
Copy link

netlify bot commented Jan 8, 2020

Deploy preview for the-carbon-components ready!

Built with commit 7d0fbf7

https://deploy-preview-4970--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Jan 8, 2020

Deploy preview for carbon-elements ready!

Built with commit 7d0fbf7

https://deploy-preview-4970--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Jan 8, 2020

Deploy preview for carbon-components-react ready!

Built with commit 7d0fbf7

https://deploy-preview-4970--carbon-components-react.netlify.com

@@ -122,6 +127,7 @@ export default class Tab extends React.Component {

render() {
const {
id,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we auto-generate this id if they don't supply one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed that auto-generation is desirable, but couldn't see a way for <TabContent> generation code to get such auto-generated ID.

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely understand, this is where some of our context experiments have taken us to help coordinate registering these ids.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right that we need some improvements in this area, I expect other approaches like render-props take into account for that.

@@ -177,7 +184,8 @@ export default class Tab extends React.Component {
onKeyDown(evt);
}}
role="presentation"
selected={selected}>
selected={selected}
aria-controls={`${id}__panel`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be on the a that has role="tab"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, fixed.

@@ -158,6 +164,7 @@ export default class Tab extends React.Component {

return (
<li
id={id}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be on the a that has role="tab"?

@asudoh asudoh requested a review from joshblack January 15, 2020 05:42
@abbeyhrt
Copy link
Contributor

@asudoh I'm not sure why but the changes are causing two new DAP violations:
Screen Shot 2020-01-15 at 11 30 19 AM

Co-Authored-By: emyarod <emyarod@users.noreply.github.com>
@asudoh asudoh dismissed joshblack’s stale review January 15, 2020 22:52

All the review comments from the reviewer have been addressed or not adequate to put in this PR's scope.

@asudoh
Copy link
Contributor Author

asudoh commented Jan 16, 2020

Good catch @abbeyhrt! Fixed.

Copy link
Member

@emyarod emyarod 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 to me, the DAP violations are resolved now

@asudoh
Copy link
Contributor Author

asudoh commented Jan 16, 2020

@joshblack Just in case you have further comments.

@asudoh asudoh merged commit ead363d into carbon-design-system:master Jan 16, 2020
@asudoh asudoh deleted the tab-aria branch January 16, 2020 22:45
joshblack pushed a commit to joshblack/carbon that referenced this pull request Jan 23, 2020
This change adds ARIA attributes to `<Tab>` and `<TabContent>` to
better describe their relationship.

Fixes carbon-design-system#4968.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tabs: Add more ARIA attributes
4 participants