Skip to content

Conversation

joshfarrant
Copy link
Contributor

@joshfarrant joshfarrant commented Jul 3, 2025

Summary

  • Ensures anchor nav is visible when it contains focus
  • Removes visibility: hidden from anchor nav to allow it to appear after the main SubNav items in the focus order
  • Adds a storybook interaction test to assert focus order in the anchor nav variant

What should reviewers focus on?

Steps to test

  • Navigate to an anchor nav variant SubNav
  • Navigate through the component using the keyboard (Tab)
  • Note that the anchor nav receives focus after the main navigation elements, and that it becomes visible

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 Jul 3, 2025

🦋 Changeset detected

Latest commit: 0ff254a

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

This PR includes changesets to release 8 packages
Name Type
@primer/react-brand Patch
@primer/brand-docs Patch
@primer/brand-css 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 Jul 3, 2025

🟢 No design token changes found

@joshfarrant joshfarrant force-pushed the joshfarrant/a11y-4675 branch from 531bdbb to 2dec325 Compare July 3, 2025 13:52
@joshfarrant joshfarrant force-pushed the joshfarrant/a11y-4675 branch from 2dec325 to 0ff254a Compare July 3, 2025 13:53
Copy link
Contributor

github-actions bot commented Jul 3, 2025

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

Copy link

@Copilot 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 PR improves keyboard navigation for the SubNav anchor variant by making anchor-based submenus visible when focused and adding a Storybook interaction test to verify focus order.

  • Refactors the anchor variant story to use StoryFn typing and a bind-based template
  • Adds a new interaction test (AnchorNavVariantKeyboardNavigation.play) that tabs through each link and verifies focus
  • Updates the changeset to document the keyboard navigation enhancement

Reviewed Changes

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

File Description
packages/react/src/SubNav/SubNav.features.stories.tsx Refactored story definitions, renamed template, added keyboard navigation play test
.changeset/breezy-shrimps-sell.md Added changeset entry describing improved keyboard navigation
Files not reviewed (1)
  • packages/react/src/SubNav/SubNav.module.css: Language not supported
Comments suppressed due to low confidence (1)

packages/react/src/SubNav/SubNav.features.stories.tsx:494

  • Consider also asserting that the anchor navigation container is visible when focused (e.g., using .toBeVisible()) to fully validate the visibility behavior introduced in this PR.
  expect(getAllByRole('button', {name: 'Learn more'})[0]).toHaveFocus()

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.

Works great @joshfarrant 👍

@joshfarrant joshfarrant merged commit d0757df into main Jul 10, 2025
18 checks passed
@joshfarrant joshfarrant deleted the joshfarrant/a11y-4675 branch July 10, 2025 13:55
@primer-css primer-css mentioned this pull request Jul 10, 2025
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.

2 participants