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

Show VideoPlayer tooltips when associated control receives focus #872

Merged
merged 6 commits into from
Jan 13, 2025

Conversation

joshfarrant
Copy link
Contributor

@joshfarrant joshfarrant commented Dec 20, 2024

Summary

Previously, the VideoPlayer component's tooltips would only show when the associated control was hovered. This PR makes them show on focus as well.

Unfortunately we can't just use the :focus pseudo-class because we need to be able to dismiss the tooltip with the Esc key.

Longer term, we'd benefit from using the PB Tooltip component, rather than this custom implementation.

This change doesn't show the tooltip when focusing the Range sliders (eg seek, volume) as those tooltips are currently bound to mouse position, which isn't relevant when using keyboard controls.

List of notable changes:

  • Show/hide VideoTooltip on focus/blur
  • Allow dismissing with Esc key
  • Remove duplicate labels from some of the controls
  • Reduce scope of mousemove listener. Previously it listened for mousemoves on the whole window, which was unnecessary.

What should reviewers focus on?

  • Check that tooltips appear when the relevant control is focused, and that they can be dismissed with Esc

Steps to test:

  1. Open one of the VideoPlayer stories
  2. Tab through the video's controls
  3. Observe that the Play, CC, Mute, and Fullscreen buttons display tooltips when they receive focus
  4. Observe that the tooltips can be dismissed with the Esc key

Supporting resources (related issues, external links, etc):

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • UI Changes contain new visual snapshots (generated by adding update snapshots label to the PR)
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Copy link

changeset-bot bot commented Dec 20, 2024

🦋 Changeset detected

Latest commit: cf1b9c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@primer/react-brand Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-config Patch
@primer/brand-storybook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Dec 20, 2024

🟢 No design token changes found

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • packages/react/src/VideoPlayer/VideoPlayer.module.css: Language not supported
Comments suppressed due to low confidence (3)

packages/react/src/VideoPlayer/components/CCButton/CCButton.tsx:21

  • The removal of the 'aria-label' attribute might affect accessibility. Ensure that the tooltip alone is sufficient for screen readers or consider retaining the 'aria-label' attribute.
aria-label={ccEnabled ? 'Disable captions' : 'Enable captions'}

packages/react/src/VideoPlayer/components/VideoTooltip/VideoTooltip.tsx:10

  • Ensure that the focus and blur event listeners correctly show and hide the tooltip. Add tests if not already covered.
const tooltipRef = useRef<HTMLDivElement>(null)

packages/react/src/VideoPlayer/components/IconControl/IconControl.tsx:12

  • Removing the aria-label attribute may affect accessibility. Consider keeping aria-label={tooltip} to ensure screen readers can provide the necessary information.
<button className={clsx(styles.VideoPlayer__iconControl, className)} {...rest}>

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

Copy link
Contributor

github-actions bot commented Dec 20, 2024

⚠️ Visual differences found

Our visual comparison tests found UI differences.

Please review the differences by using the test artifacts to ensure that the changes were intentional.

Artifacts can be downloaded and reviewed locally.

Download links are available at the bottom of the workflow summary screen.

Example:

artifacts section of workflow run

If the changes are expected, please run npm run test:visual:update-snapshots to replace the previous fixtures.

Review visual differences

@joshfarrant joshfarrant force-pushed the joshfarrant/videoplayer-tooltip-focus branch from 6f3db51 to 18707d8 Compare January 6, 2025 14:39
@joshfarrant joshfarrant force-pushed the joshfarrant/videoplayer-tooltip-focus branch from 18707d8 to ab962cd Compare January 10, 2025 09:58
Copy link
Collaborator

@rezrah rezrah left a comment

Choose a reason for hiding this comment

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

Looks great, @joshfarrant.

Few things to add before we merge:

  • Needs a changeset for the React package
  • Could you add a interaction test to Storybook please. We should have the focus state under visual test coverage given it's a MAS-related requirement (prior art here)

Feel free to ping me if you want another review

@joshfarrant
Copy link
Contributor Author

joshfarrant commented Jan 10, 2025

@rezrah Great spot + suggestion, thanks!

Changeset and interaction test added, I'll hold off merging until you've had chance to look. Give it another ✅ when you're happy

Copy link
Collaborator

@rezrah rezrah left a comment

Choose a reason for hiding this comment

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

Looks good 👍

You should have a new snapshot added to this PR but can't see it, could you run the tests again please?

@joshfarrant joshfarrant force-pushed the joshfarrant/videoplayer-tooltip-focus branch from a45859e to 51f33fd Compare January 13, 2025 16:44
@joshfarrant joshfarrant force-pushed the joshfarrant/videoplayer-tooltip-focus branch from 41a2dce to 33870b0 Compare January 13, 2025 17:03
@joshfarrant joshfarrant merged commit 872bdcf into main Jan 13, 2025
17 checks passed
@joshfarrant joshfarrant deleted the joshfarrant/videoplayer-tooltip-focus branch January 13, 2025 17:33
@primer-css primer-css mentioned this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants