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

Xander/carousel accessibility compliance #1416

Closed
wants to merge 13 commits into from

Conversation

xman343
Copy link
Contributor

@xman343 xman343 commented Jul 18, 2023

Changes

Bringing Carousel component to accessibility compliance by distributing proper roles and labels within the component.

Addresses #1148.

Testing

Evaluated using Cypress a11y tests. Unit & visual testing conducted as needed.

Docs

N/A

@xman343 xman343 added the a11y Accessibility issues (keyboard navigation, color contrast, assistive technologies, semantics, etc) label Jul 18, 2023
@xman343 xman343 self-assigned this Jul 18, 2023
@xman343 xman343 marked this pull request as ready for review July 19, 2023 18:59
@xman343 xman343 requested review from a team as code owners July 19, 2023 18:59
@xman343 xman343 requested review from mayank99 and LostABike and removed request for a team July 19, 2023 18:59
@@ -51,7 +51,6 @@ export const CarouselSlide = React.forwardRef((props, ref) => {
<Box
as='li'
className={cx('iui-carousel-slider-item', className)}
role='tabpanel'
Copy link
Contributor

Choose a reason for hiding this comment

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

i believe you need role='group' when using aria-roledescription

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding that role causes MainExample and ControlledExample to fail. These errors were present before I started this PR as well, and removing the original tabpanel role got rid of them. If you think it's necessary, I can try to look for another way to fix these issues while keeping the group (or tabpanel) role.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

that's interesting, because APG suggests using role=group (check the heading "Basic carousel elements")

i believe it might be because we are using li. we could make it a generic div. if we do that, the parent ol would also need to be a div.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -46,8 +46,7 @@ export default () => {
{gradients.map(({ from, to }, index) => (
<li
key={index}
role='tabpanel'
id={`${id}-slide-${index}`}
id={`${id}--slide-${index}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this id changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a typo in the example that caused it to throw an error. It was supposed to be --slide-, which is the format used in the CarouselDotsList component.
image

Copy link
Contributor

@mayank99 mayank99 Jul 19, 2023

Choose a reason for hiding this comment

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

hmm i think this behavior is actually wrong. CarouselDotsList is the component, whereas Carousel.onlyDots is the example; the latter should not rely on implementation details of the former.

i wonder if we even need id and aria-controls. since we removed role=tabpanel in #1416 (comment), i think role=tab can also be removed from CarouselDot. i will double check tomorrow.

you can also try to read through APG on your own and compare our markup with theirs.

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 removed role=tab from CarouselDot myself, and it generated these violations. I think we have to keep this role, unless something else can be changed that would allow us to remove it.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

so i've been looking into this and need more time. I think fixing Carousel accessibility would require some bigger changes across the whole component, so you could move this PR to draft and work on a different PR in the meantime.

i will pick up Carousel later

@xman343
Copy link
Contributor Author

xman343 commented Jul 20, 2023

There's a unit test that's failing, so I'm going to work on that too.

@xman343
Copy link
Contributor Author

xman343 commented Jul 20, 2023

Done, just had to update a querySelector (ul -> div) and a role (tabpanel -> group)

@xman343 xman343 marked this pull request as draft July 26, 2023 21:01
@FlyersPh9 FlyersPh9 closed this Aug 21, 2023
@FlyersPh9 FlyersPh9 deleted the xander/carousel-accessibility-compliance branch August 21, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Accessibility issues (keyboard navigation, color contrast, assistive technologies, semantics, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants