From 270403e6346fff3223dcfcee1f097bdc486fded4 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 3 Feb 2025 12:30:19 -0500 Subject: [PATCH] backport SL-2353 --- docs/docs/resources/changelog.md | 2 ++ src/components/carousel/carousel.ts | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/docs/resources/changelog.md b/docs/docs/resources/changelog.md index 9c11bcbac..57d42c8cb 100644 --- a/docs/docs/resources/changelog.md +++ b/docs/docs/resources/changelog.md @@ -19,6 +19,8 @@ During the alpha period, things might break! We take breaking changes very serio - Fixed a number of broken event listeners throughout the docs - Fixed a bug in `` that prevented slots from showing automatically without `with-` attributes - Fixed a bug in `` that prevented the placeholder color from being customized with the `--wa-form-control-placeholder-color` token +- Improved accessibility of `` + ## 3.0.0-alpha.10 diff --git a/src/components/carousel/carousel.ts b/src/components/carousel/carousel.ts index fdc930be9..62de6acfa 100644 --- a/src/components/carousel/carousel.ts +++ b/src/components/carousel/carousel.ts @@ -378,8 +378,16 @@ export default class WaCarousel extends WebAwesomeElement { this.getSlides({ excludeClones: false }).forEach((slide, index) => { slide.classList.remove('--in-view'); slide.classList.remove('--is-active'); + slide.setAttribute('role', 'group'); slide.setAttribute('aria-label', this.localize.term('slideNum', index + 1)); + if (this.pagination) { + slide.setAttribute('role', 'tabpanel'); + slide.removeAttribute('aria-label'); + slide.setAttribute('aria-labelledby', `tab-${index + 1}`); + slide.setAttribute('id', `slide-${index + 1}`); + } + if (slide.hasAttribute('data-clone')) { slide.remove(); } @@ -633,7 +641,7 @@ export default class WaCarousel extends WebAwesomeElement { : ''} ${this.pagination ? html` -