Skip to content
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

Keyboard accessibility for Preview #878

Closed
jamesball27 opened this issue May 6, 2020 · 2 comments
Closed

Keyboard accessibility for Preview #878

jamesball27 opened this issue May 6, 2020 · 2 comments

Comments

@jamesball27
Copy link

Currently the Preview component only attaches an onClick handler and does not have a tabindex="0" attribute. This means that the video can only be played through a mouseclick event, and it is completely inaccessible from the keyboard when the light prop is enabled.

I've resorted to the following hacky workaround that manually calls the handleClickPreview method, but it would be nice to either include a keypress event by default or at the very least allow one to be passed into the Preview component's props.

interface Props {
  url: string;
}

interface ReactPlayerExtraProps {
  handleClickPreview: () => void;
}

const Video: React.FC<Props> = ({ url }) => {
  const playerRef = useRef<ReactPlayerExtraProps>(null);

  return (
    <div
      tabIndex={0}
      onKeyPress={e => {
        if (e.key === 'Enter' && playerRef.current) {
          playerRef.current.handleClickPreview();
        }
      }}
    >
      <ReactPlayer ref={playerRef} url={url} light />
    </div>
  );
}

Here's a codesandbox demonstrating the issue https://codesandbox.io/s/romantic-platform-hsger - you'll notice that you can't tab into the first player, but the second is accessible by keyboard.

Webmaster1116 added a commit to Webmaster1116/video-player that referenced this issue May 20, 2021
@bweisberger
Copy link

The preview still has accessibility issues after this fix.

Pressing Enter or Space does now play the video, but the preview div is removed from the DOM after the video starts, so the user loses keyboard focus on the video element.

Because the Space Bar also causes the screen to scroll for easy navigation, this means pressing Space also causes the visible window to scroll down past the video, and in either case you'll need to tab back to the video to control it with the keyboard again after the preview disappears and the video starts.

webmiraclepro added a commit to webmiraclepro/video-player that referenced this issue Sep 9, 2022
@Toxicom
Copy link

Toxicom commented Jan 30, 2024

@cookpete Looks like the issue @bweisberger described is still present - any information on this? Right now the player is not keyboard accessible.

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

No branches or pull requests

3 participants