Skip to content

Conversation

joshfarrant
Copy link
Contributor

@joshfarrant joshfarrant commented Aug 22, 2025

ℹ️ This is a follow-on PR from #1137. It will be rebased from main and marked as ready-for-review once that PR has been merged. It is also blocked by #1146 as that PR fixes a bug in the Tabs component where aria-labelledby wasn't being passed through to the useTabs hook.

Summary

Improves types in useTabs hook, improves useTabs tests, and fixes an accessibility issue in the IDE component which these type improvements automatically highlighted.

List of notable changes

  • Fixes incorrect onClick, onKeyDown, and onFocus types
  • Enforces that either a label or labelledBy is passed to getTabListProps()
  • Updates the focusTab function to only focus the element and nothing else. onFocus will handle the state updates. Previously two duplicate state updates were being triggered.
  • Generally makes typings in the hook more accurate
  • Removes @ts-expect-error from useTabs.test.tsx, now that the types are fixed
  • Adds a missing label to the tablist in the IDE component (thanks, TypeScript! 🎉)

What should reviewers focus on?

  • Check out the test tweaks
  • Make sure you're happy with the type changes to useTabs. There are no changes to functionality, just types.
  • Make sure you're happy with the new tablist label in the IDE component.

Steps to test

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

Screenshots

Before After
image image

Copy link

changeset-bot bot commented Aug 22, 2025

🦋 Changeset detected

Latest commit: b77d5e4

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

@joshfarrant joshfarrant changed the title Joshfarrant/use tabs type improvements Improves types in useTabs hook Aug 22, 2025
Copy link
Contributor

github-actions bot commented Aug 22, 2025

🟢 No design token changes found

Copy link
Contributor

github-actions bot commented Aug 22, 2025

🟢 No unit test coverage changes found

All components with tests maintain the same coverage as the main branch.

Copy link
Contributor

github-actions bot commented Aug 22, 2025

🟢 No visual differences found

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

@joshfarrant joshfarrant force-pushed the joshfarrant/use-tabs-type-improvements branch from faf5fa0 to b77d5e4 Compare September 4, 2025 07:07
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.

1 participant