From 0216f43e99e8e23c4e43c105cc6a81093c008750 Mon Sep 17 00:00:00 2001 From: Michael Bourne Date: Wed, 28 Aug 2024 17:47:54 -0600 Subject: [PATCH 1/2] Add containerRole parameter to a11y module To fix accessibility error related to aria-roledescription --- src/modules/a11y/a11y.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/a11y/a11y.mjs b/src/modules/a11y/a11y.mjs index 97ead239d..f76177d83 100644 --- a/src/modules/a11y/a11y.mjs +++ b/src/modules/a11y/a11y.mjs @@ -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, @@ -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; From fcd0c86a659fc6d8e785823de858b38827ee3bec Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Thu, 29 Aug 2024 12:43:53 +0300 Subject: [PATCH 2/2] add types --- src/types/modules/a11y.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types/modules/a11y.d.ts b/src/types/modules/a11y.d.ts index 67cb64a57..21b352a20 100644 --- a/src/types/modules/a11y.d.ts +++ b/src/types/modules/a11y.d.ts @@ -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 *