Skip to content

feat: add focus state to sliders and volume slider#60

Merged
luwes merged 4 commits intomainfrom
a11y
Oct 21, 2025
Merged

feat: add focus state to sliders and volume slider#60
luwes merged 4 commits intomainfrom
a11y

Conversation

@luwes
Copy link
Copy Markdown
Collaborator

@luwes luwes commented Oct 15, 2025

This pull request refactors several media control button components (FullscreenButton, MuteButton, PlayButton) in the React package for improved type safety and consistency, enhances accessibility and keyboard navigation for sliders, and updates styling for better focus visibility and UI clarity. The changes also improve the popover's accessibility by managing focus more robustly.

Component Refactoring and Type Improvements:

  • Refactored button state and props hooks for FullscreenButton, MuteButton, and PlayButton to use more precise types (ReturnType<typeof ...>) and renamed prop hooks to get...Props for clarity and consistency. Updated connected component creation to use the new prop hook names. [1] [2] [3] [4] [5] [6]
  • Removed outdated type exports and unnecessary comments related to type issues in these components. [1] [2] [3]

Accessibility and Keyboard Navigation:

  • Added tabIndex={0} to both TimeSlider and VolumeSlider root elements, making them keyboard focusable. Updated ARIA attributes to reflect actual slider values (e.g., aria-valuenow, aria-valuemax) for better screen reader support. [1] [2]
  • Added type="button" to button elements to prevent unintended form submissions and clarify intent. [1] [2] [3]

Popover and Focus Management:

  • Integrated FloatingFocusManager into the Popover.Popup component to manage keyboard focus when the popover is open, improving accessibility for keyboard and assistive technology users. Set the initial focus to the popover's reference element. [1] [2]
  • Set a default portal ID in PopoverPortal to ensure consistent portal mounting.

Styling and Focus Visibility:

  • Updated slider root styles in both the default and toasted media skins to add rounded corners and enhanced focus outlines, improving visual clarity and accessibility. Added specific styles for TimeSliderRoot and VolumeSliderRoot to control focus outline offsets. [1] [2] [3] [4]
  • Applied new styles in the default skin by adding the new class names to TimeSlider.Root and VolumeSlider.Root usages. [1] [2]

These changes collectively improve code maintainability, accessibility, and user experience across the media control components.

@luwes luwes requested a review from Copilot October 15, 2025 18:13
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
vjs-10-demo-html Ready Ready Preview Comment Oct 21, 2025 0:16am
vjs-10-demo-react Ready Ready Preview Comment Oct 21, 2025 0:16am
vjs-10-website Ready Ready Preview Comment Oct 21, 2025 0:16am

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances accessibility and keyboard navigation for media control components while refactoring button components for improved type safety. The changes focus on making sliders keyboard focusable, improving focus visibility, and cleaning up type definitions.

  • Added keyboard focus support (tabIndex={0}) to TimeSlider and VolumeSlider components
  • Enhanced focus styling with rounded corners and outline offsets for better visual accessibility
  • Refactored button components (FullscreenButton, MuteButton, PlayButton) with cleaner type definitions and renamed prop hooks

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/react/react/src/components/TimeSlider.tsx Added tabIndex and corrected ARIA attributes for keyboard accessibility
packages/react/react/src/components/VolumeSlider.tsx Added tabIndex and corrected ARIA attributes for keyboard accessibility
packages/react/react/src/components/Popover.tsx Integrated FloatingFocusManager for better focus management and added default portal ID
packages/react/react/src/skins/default/styles.ts Added focus styles for slider roots and specific TimeSlider/VolumeSlider styling
packages/react/react/src/skins/toasted/styles.ts Enhanced focus styling with rounded corners and outline offsets
packages/react/react/src/skins/default/types.ts Added new style properties for TimeSliderRoot and VolumeSliderRoot
packages/react/react/src/skins/default/MediaSkinDefault.tsx Applied new style classes to slider components
packages/react/react/src/components/FullscreenButton.tsx Refactored types and added button type attribute
packages/react/react/src/components/MuteButton.tsx Refactored types and added button type attribute
packages/react/react/src/components/PlayButton.tsx Refactored types and added button type attribute

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/react/react/src/components/VolumeSlider.tsx Outdated
Comment thread packages/react/react/src/components/VolumeSlider.tsx Outdated
@vercel vercel bot temporarily deployed to Preview – vjs-10-website October 15, 2025 18:19 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-html October 15, 2025 18:19 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-react October 15, 2025 18:19 Inactive
}

function PopoverPortal({ children, root, rootId }: PopoverPortalProps): JSX.Element {
function PopoverPortal({ children, root, rootId = '@default_portal_id' }: PopoverPortalProps): JSX.Element {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: should we stick to kebab case for IDs?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good call, this is something @cjpillsbury added with the intention of removing in the future so not too worried about it.

@vercel vercel bot temporarily deployed to Preview – vjs-10-website October 21, 2025 00:16 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-html October 21, 2025 00:16 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-react October 21, 2025 00:16 Inactive
@luwes luwes marked this pull request as ready for review October 21, 2025 20:43
@luwes luwes merged commit f514051 into main Oct 21, 2025
4 checks passed
@luwes luwes deleted the a11y branch October 21, 2025 20:44
@github-actions github-actions bot mentioned this pull request Oct 24, 2025
@github-actions github-actions bot mentioned this pull request Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants