Skip to content

Commit d03044e

Browse files
authored
feat(a11y): add wrapperLiveRegion param to disable wrapper live region in a11y module (#8061)
1 parent b34bdce commit d03044e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/modules/a11y/a11y.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function A11y({ swiper, extendParams, on }) {
2525
slideRole: 'group',
2626
id: null,
2727
scrollOnFocus: true,
28+
wrapperLiveRegion: true,
2829
},
2930
});
3031

@@ -318,9 +319,11 @@ export default function A11y({ swiper, extendParams, on }) {
318319
const wrapperEl = swiper.wrapperEl;
319320
const wrapperId =
320321
params.id || wrapperEl.getAttribute('id') || `swiper-wrapper-${getRandomNumber(16)}`;
321-
const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
322322
addElId(wrapperEl, wrapperId);
323-
addElLive(wrapperEl, live);
323+
if (params.wrapperLiveRegion) {
324+
const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
325+
addElLive(wrapperEl, live);
326+
}
324327

325328
// Slide
326329
initSlides();

src/types/modules/a11y.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,11 @@ export interface A11yOptions {
107107
* @default true
108108
*/
109109
scrollOnFocus?: boolean;
110+
/**
111+
* Whether or not the swiper-wrapper should have the `aria-live` attribute applied to it.
112+
* If true, the value will be `off` when autoplay is enabled, otherwise it will be `polite`
113+
*
114+
* @default true
115+
*/
116+
wrapperLiveRegion?: boolean;
110117
}

0 commit comments

Comments
 (0)