Skip to content

Commit

Permalink
feat(a11y): add containerRole parameter (#7708)
Browse files Browse the repository at this point in the history
* Add containerRole parameter to a11y module

To fix accessibility error related to aria-roledescription

* add types

---------

Co-authored-by: Vladimir Kharlampidi <[email protected]>
  • Loading branch information
michaelbourne and nolimits4web authored Aug 29, 2024
1 parent d79f6e5 commit 1542c01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/modules/a11y/a11y.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function A11y({ swiper, extendParams, on }) {
slideLabelMessage: '{{index}} / {{slidesLength}}',
containerMessage: null,
containerRoleDescriptionMessage: null,
containerRole: null,
itemRoleDescriptionMessage: null,
slideRole: 'group',
id: null,
Expand Down Expand Up @@ -302,6 +303,9 @@ export default function A11y({ swiper, extendParams, on }) {
if (params.containerMessage) {
addElLabel(containerEl, params.containerMessage);
}
if (params.containerRole) {
addElRole(containerEl, params.containerRole);
}

// Wrapper
const wrapperEl = swiper.wrapperEl;
Expand Down
7 changes: 7 additions & 0 deletions src/types/modules/a11y.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export interface A11yOptions {
*/
containerRoleDescriptionMessage?: string | null;

/**
* Value of the "role" attribute to be set on the swiper container
*
* @default null
*/
containerRole?: string | null;

/**
* Message for screen readers describing the role of slide element
*
Expand Down

0 comments on commit 1542c01

Please sign in to comment.