-
Notifications
You must be signed in to change notification settings - Fork 595
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
Update accessible roles for v5 #1031
Conversation
…le will be announced.
…istinguish, update tests.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
}); | ||
|
||
const carouselFrame = screen.getByRole('region'); | ||
const sliderFrame = screen.getByTestId(`${carouselId}-slider-frame`); |
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.
The region role is now applied to the whole carousel, this ensures the same slider frame element is being selected.
/** | ||
* Unique id attribute for the carousel which may be referenced by aria attributes. | ||
*/ | ||
carouselId: string; |
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.
I went with carouseld
to disambiguate between id
attributes and props on other elements.
/** | ||
* Whether tab pagination is used to set appropriate roles for slides. | ||
*/ | ||
tabbed: boolean; |
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.
tabbed
doesn't exactly align with the "pagination" and "dots" verbiage currently used, but it aligns with WCAG terminology.
<div | ||
className={pagingDotsContainerClassName} | ||
style={listStyles} | ||
aria-label="Choose slide to display." |
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.
Should we let this be customizable with this string as default? (maybe this is more for an eventual port of this for v6 and not this specific use case)
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.
Thank you for these improvements and getting this more inline. This will be also great to forward-port to v6 as well.
I'm not worried about the failed Vercel deployment on v5 since those docs are decommissioned, nor the Cypress tests on v5 since we knew those were broken in CI.
* Migrate accessibility roles from v5 to v6 * Fix storybook configuration * Fix existing Cypress tests * Add query param support to demo used by cypress * Fix serializing params for tests. * Update demos.tsx * Fix auto install peers * Update cypress.config.ts * Update carousel.test.tsx * Add axe test violation checker for a carousel with control callbacks * Add changeset * Switch to major bump for new a11y props.
Description
Adjusts roles and attributes to better align with the WCAG Aria Authoring Practices Guide https://www.w3.org/WAI/ARIA/apg/patterns/carousel
tabbed
prop determines whether roles should follow the Basic Carousel or Tabbed Carousel requirements.landmark
prop determines whether role should be aregion
landmark or have rolegroup
. Role and label have been moved from the slider frame to the parent carousel element so controls are contained within the label and role. Landmark regions should be intentional, so the default value is set to false.carouselId
prop gives the carousel frame anid
attribute which can be uniquely targeted by controls where there might be multiple carousels on a page. This could be replaced internally withuseId
with React 18.frameAriaLabel
has been changed to a slightly more useful 'Slider', the role description of 'carousel' will already be announcedtab
, andaria-controls
targeting their slide.tablist
. Astab
s need to be the immediate child oftablist
, and sincetablist
already has list semantics,ul
andli
have been removed. This should resolve Attributes do not match their roles on carousel dots #1001 and the issue raised in Testing accessibility with jest-axe #803 regardingaria-selected
.tabbed
is true, slides will have the roletabpanel
indicating they are the target of thetab
, otherwise they will have the rolegroup
and a description ofslide
.tabbed
is false, default pagination dots will not be rendered.aria-controls
.Adds dev dependencies:
jest-axe
,@types/jest-axe
Fixes #1001
Type of Change
These changes will impact the roles and attributes when default props are used. I believe this will improve accessibility but may be considered a breaking change.
How Has This Been Tested?
New jest and cypress tests were added. Existing cypress tests needed wait logic to pass, akin to this change 1f7f020
Cypress and Jest tests and Lighthouse accessibility report should all pass. Attributes and roles can be verified in devtools.
Checklist
pnpm run lint
)pnpm run test:ci-with-server
/pnpm run test
)pnpm changeset
.