Skip to content

Conversation

@llefebvre
Copy link
Contributor

@llefebvre llefebvre commented Jan 10, 2026

MED-1960

Clean up accessibility properties for media-player slider-bar element.

Summary of changes:

  • Removed duplicate aria-* attributes from <d2l-labs-slider-bar> element in media-player.js.
  • Move all aria-* attributes from sliderBar to sliderContainer
  • move keypress event listener to sliderContainer

The focus looks slightly different now that it is on the sliderContainer instead of the sliderBar. In the screenshot below, the new focus look is shown in the upper image. (The border of the slider bar is now more visible than before with a heavier line)

MED-1960-VolumeSliderFocus-comparison

Tested keyboard navigation and keypress functionality in the demo application and in local instance of media-player (Media Library video preview and edit dialogs).

@llefebvre llefebvre requested review from a team as code owners January 10, 2026 00:43
@github-actions
Copy link
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/labs/pr-869/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

@llefebvre llefebvre requested a review from dbatiste January 12, 2026 18:58
super.connectedCallback();
window.addEventListener('mouseup', () => { this._barUp(); });
window.addEventListener('mousemove', (event) => { this._onTrack(event); });
if (!this.label) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For required properties we normally would try to use PropertyRequiredMixin. Here is an example were we use it: https://github.com/BrightspaceUI/core/blob/main/components/dialog/dialog.js#L50

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (!this.label) {
console.error('d2l-labs-slider-bar requires a "label" property for accessibility');
}
this.setAttribute('aria-label', this.label || 'slider');
Copy link
Contributor

@dbatiste dbatiste Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we apply these to the internal sliderContainer element? That would avoid the need to sprout them on the host, as well as avoid the need to sync them in updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@llefebvre llefebvre requested a review from dbatiste January 13, 2026 19:24
<div id="sliderContainer"
role="slider"
tabindex="0"
aria-label="${this.label}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the title attribute that's being set from the media-palyer? Is it to show the native browser tooltip on hover? If so, perhaps it can be applied here instead, so that it's not up to the consumer to do this. It looks like we're setting the same value for the label and the title, so we would already have the value we need here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the best practise is to eliminate it if you already have aria-label, so I removed it. For sighted users, I believe the tooltip is redundant and therefore of little value.

Using both can cause some screen readers to announce the label twice, which creates a bad user experience.
The best practice is to use aria-label for the accessible name and consider an alternative, script-based tooltip solution if a visual tooltip is essential.

aria-valuemin="${String(this.min)}"
aria-valuemax="${String(this.max)}"
aria-valuenow="${String(ariaValueNow)}"
@keydown=${this._onKeyPress}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I know the handler was already named this, but I'd normally name this _onKeyDown to align with the event... just to minimize any possible confusion reading the code in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed.

Copy link
Contributor

@dbatiste dbatiste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval so I'm not blocking you. I'd probably do those last couple tweaks though.

@llefebvre llefebvre merged commit f87d735 into main Jan 15, 2026
5 checks passed
@llefebvre llefebvre deleted the llefebvre/MED-1960-move-slider-role branch January 15, 2026 00:46
@d2l-github-release-tokens
Copy link

🎉 This PR is included in version 2.42.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants