-
Notifications
You must be signed in to change notification settings - Fork 760
[Carousel] Accessibility improvments - v2 #3018
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,8 @@ | |
| data-panelcontainer="${wcmmode.edit && 'carousel'}" | ||
| id="${carousel.id}" | ||
| class="cmp-carousel" | ||
| role="group" | ||
| role="region" | ||
| aria-label="${carousel.accessibilityLabel}" | ||
| aria-live="polite" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing aria-live="polite" seems like a good change. Auto-rotating carousels can otherwise keep announcing updates and become noisy for screen reader users. |
||
| aria-roledescription="carousel" | ||
| data-cmp-is="carousel" | ||
| data-cmp-autoplay="${(wcmmode.edit || wcmmode.preview) ? '' : carousel.autoplay}" | ||
|
|
@@ -40,11 +39,11 @@ | |
| id="${item.id}-tabpanel" | ||
| class="cmp-carousel__item${item.name == carousel.activeItem ? ' cmp-carousel__item--active' : ''}" | ||
| role="tabpanel" | ||
| aria-labelledby="${item.id}-tab" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new "Slide X of Y" label is clearer than relying on aria-labelledby. Quick question: does itemList.count start at 1 here? Just checking to avoid the first slide being announced as “Slide 0”. |
||
| aria-roledescription="slide" | ||
| aria-label="${(carousel.accessibilityAutoItemTitles && item.title) || 'Slide {0} of {1}' @ format=[itemList.count, carousel.items.size], i18n}" | ||
| data-cmp-data-layer="${item.data.json}" | ||
| data-cmp-hook-carousel="item"></div> | ||
| data-cmp-hook-carousel="item" | ||
| tabindex="-1"></div> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed tabindex="-1" was added to the slide container. Is this used for programmatic focus when slides change? Just wanted to confirm the intent. |
||
| <sly data-sly-call="${controlsTemplate.controls @ carousel=carousel}" data-sly-test="${!carousel.controlsPrepended}"></sly> | ||
| <ol class="cmp-carousel__indicators" | ||
| role="tablist" | ||
|
|
@@ -53,9 +52,12 @@ | |
| <li data-sly-repeat.item="${items}" | ||
| id="${item.id}-tab" | ||
| class="cmp-carousel__indicator${item.name == carousel.activeItem ? ' cmp-carousel__indicator--active' : ''}" | ||
| role="tab" | ||
| role="tab" | ||
| aria-controls="${item.id}-tabpanel" | ||
| aria-label="${'Slide {0}' @ format=[itemList.count], i18n}" | ||
| aria-label="${'Slide {0}' @ format=[itemList.count], i18n} ${item.title}" | ||
| title="${'Slide {0}' @ format=[itemList.count], i18n} ${item.title}" | ||
| tabindex="${item.name == carousel.activeItem ? '0' : '-1'}" | ||
| aria-selected="${item.name == carousel.activeItem ? 'true' : 'false'}" | ||
| data-cmp-hook-carousel="indicator">${item.title}</li> | ||
| </ol> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,13 +19,15 @@ | |
| <button class="cmp-carousel__action cmp-carousel__action--previous" | ||
| type="button" | ||
| aria-label="${carousel.accessibilityPrevious || 'Previous' @ i18n}" | ||
| title="${carousel.accessibilityPrevious || 'Previous' @ i18n}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the title attribute on the navigation buttons looks helpful for hover tooltips. Since we already have aria-label, this shouldn’t affect accessibility behavior, right? |
||
| data-cmp-hook-carousel="previous"> | ||
| <span class="cmp-carousel__action-icon"></span> | ||
| <span class="cmp-carousel__action-text">${carousel.accessibilityPrevious || 'Previous' @ i18n}</span> | ||
| </button> | ||
| <button class="cmp-carousel__action cmp-carousel__action--next" | ||
| type="button" | ||
| aria-label="${carousel.accessibilityNext || 'Next' @ i18n}" | ||
| title="${carousel.accessibilityNext || 'Next' @ i18n}" | ||
| data-cmp-hook-carousel="next"> | ||
| <span class="cmp-carousel__action-icon"></span> | ||
| <span class="cmp-carousel__action-text">${carousel.accessibilityNext || 'Next' @ i18n}</span> | ||
|
|
@@ -34,6 +36,7 @@ | |
| class="cmp-carousel__action cmp-carousel__action--pause" | ||
| type="button" | ||
| aria-label="${carousel.accessibilityPause || 'Pause' @ i18n}" | ||
| title="${carousel.accessibilityPause || 'Pause' @ i18n}" | ||
| data-cmp-hook-carousel="pause"> | ||
| <span class="cmp-carousel__action-icon"></span> | ||
| <span class="cmp-carousel__action-text">${carousel.accessibilityPause || 'Pause' @ i18n}</span> | ||
|
|
@@ -42,6 +45,7 @@ | |
| class="cmp-carousel__action cmp-carousel__action--play cmp-carousel__action--disabled" | ||
| type="button" | ||
| aria-label="${carousel.accessibilityPlay || 'Play' @ i18n}" | ||
| title="${carousel.accessibilityPlay || 'Play' @ i18n}" | ||
| data-cmp-hook-carousel="play"> | ||
| <span class="cmp-carousel__action-icon"></span> | ||
| <span class="cmp-carousel__action-text">${carousel.accessibilityPlay || 'Play' @ i18n}</span> | ||
|
|
||
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.
Switching from role="group" to role="region" makes sense here since the carousel is a distinct section. Just wondering if we should ensure carousel.accessibilityLabel is always present so the region doesn’t end up unnamed for screen readers.