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(tab): add aria-disabled depending on disabled prop #4698

Merged
merged 15 commits into from
Nov 18, 2019
Merged

fix(tab): add aria-disabled depending on disabled prop #4698

merged 15 commits into from
Nov 18, 2019

Conversation

abbeyhrt
Copy link
Contributor

Removes DAP violation for disabled state of the Tab Component.

Changelog

New

  • aria-disabled={disabled} on the li
  • tests for aria-disabled

Testing / Reviewing

Go to the Tabs, check the "disabled" knob and run DAP. Verify that this is the only violation you see:
Screen Shot 2019-11-15 at 12 19 49 PM

@abbeyhrt abbeyhrt requested a review from a team as a code owner November 15, 2019 18:35
@ghost ghost requested review from asudoh and vpicone November 15, 2019 18:35
@abbeyhrt abbeyhrt requested review from aledavila and dakahn November 15, 2019 18:36
@vpicone

This comment has been minimized.

@netlify
Copy link

netlify bot commented Nov 15, 2019

Deploy preview for the-carbon-components ready!

Built with commit 85dbfcf

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

@netlify
Copy link

netlify bot commented Nov 15, 2019

Deploy preview for carbon-elements ready!

Built with commit 85dbfcf

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

@netlify
Copy link

netlify bot commented Nov 15, 2019

Deploy preview for carbon-components-react ready!

Built with commit 85dbfcf

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

@abbeyhrt
Copy link
Contributor Author

@vpicone let me know if I'm misunderstanding something but I think my description might have been misleading! These are the violations I'm trying to remove when the tabs are disabled:
Screen Shot 2019-11-15 at 12 47 56 PM

You totally might know this but the "All content must reside within a HTML5..." violation is always present because of something with storybook and isn't a problem with any component.

packages/react/src/components/Tab/Tab-test.js Outdated Show resolved Hide resolved
packages/react/src/components/Tab/Tab-test.js Outdated Show resolved Hide resolved
@@ -160,6 +160,7 @@ export default class Tab extends React.Component {
{...other}
tabIndex={-1}
className={classes}
aria-disabled={disabled}
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this pair with role="presentation"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does remove the DAP violation but as Vince said, since the error is coming from the anchor tag, the aria-disabled should live there so I'm gonna move it!

@vpicone
Copy link
Contributor

vpicone commented Nov 15, 2019

@abbeyhrt totally! Adding aria-disabled tells DAP that the contrast isn't a concern. If you click on those errors you'll see they point to the anchor tag, not the li.

Apply the li's have role='presentation' which removes semantic meaning, so we might prefer to add the aria-disabled to the anchor tag where the issues showing up.

Also, any reason to use aria-disabled as opposed to the disabled attribute?

@netlify
Copy link

netlify bot commented Nov 15, 2019

Deploy preview for carbon-elements ready!

Built with commit 79ca5e2

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

@netlify
Copy link

netlify bot commented Nov 15, 2019

Deploy preview for the-carbon-components ready!

Built with commit 79ca5e2

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

@netlify
Copy link

netlify bot commented Nov 15, 2019

Deploy preview for carbon-components-react ready!

Built with commit 79ca5e2

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

@abbeyhrt
Copy link
Contributor Author

abbeyhrt commented Nov 15, 2019

@vpicone I'll switch it the the a tag! And really it's just what I know to do, no particular reason. How would I apply disabled instead? I'm not sure how and what i've tried isn't removing the DAP violations.

@vpicone
Copy link
Contributor

vpicone commented Nov 15, 2019

@abbeyhrt sorry, I forgot they were anchor tags, not buttons. you were spot on with the aria-disabled.

Speaking of....why are they anchor tags!? They take an href but don't go anywhere?

@abbeyhrt
Copy link
Contributor Author

@vpicone I have no idea why but I'm not touching that lol

@vpicone
Copy link
Contributor

vpicone commented Nov 15, 2019

@abbeyhrt i don't blame you lol

@@ -110,6 +110,19 @@ describe('Tab', () => {
});
});
});

it('should set aria-disabled to the value of the disabled prop', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to render it without the disabled prop at all, ensure that it can't find the element, then find the element using the attribute once the prop has been set?

That way we're also testing the case where no prop is provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm really new to testing so bear with me, how do I check that it can't find the element? In my head it would be something like expect(getDisabledRegion().prop('aria-disabled')).toBe(undefined); with disabled not set yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, figured it out!

@asudoh asudoh merged commit 79be49d into carbon-design-system:master Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants