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

Tabs: cleanup and improvements #56224

Merged
merged 7 commits into from
Nov 17, 2023
Merged

Tabs: cleanup and improvements #56224

merged 7 commits into from
Nov 17, 2023

Conversation

chad1008
Copy link
Contributor

What?

A few small updates to the Tabs component family:

  1. use useTabContext() consistently, instead of sometimes using useContext()
  2. memoize the context value
  3. expose Tabs.Context
  4. add sub-components to Storybook

Why?

These are items that came up while working on other things. While they could be broken into their own separate PRs, they felt small enough to batch together. More specifically:

useTabContext()
No change in behavior here, it just wasn't being used consistently

Memoize context value
Was causing unnecessary re-renders.

Expose Tabs.Context
In some implications involving slot/fills, it's necessary to wrap subcomponents in an additional context provider. See #55360 for a real-life example. This also meant updating the warning thrown when context is missing to include the possibility of using a Tabs.Context.Provider

Add sub-components to Storybook
I forgot them initially, but now they can be viewed in the component docs in Storybook.

Testing Instructions

N/A, other than making sure all the tests pass.

@chad1008 chad1008 added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Nov 16, 2023
@chad1008 chad1008 requested a review from a team November 16, 2023 18:50
@chad1008 chad1008 self-assigned this Nov 16, 2023
Copy link

github-actions bot commented Nov 16, 2023

Flaky tests detected in 34ae69d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6897370662
📝 Reported issues:

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Good to be merged once comments are addressed

packages/components/src/tabs/tab.tsx Outdated Show resolved Hide resolved
@chad1008 chad1008 enabled auto-merge (squash) November 17, 2023 15:15
@chad1008 chad1008 merged commit bb8adcd into trunk Nov 17, 2023
50 checks passed
@chad1008 chad1008 deleted the tabs-cleanup branch November 17, 2023 16:04
@github-actions github-actions bot added this to the Gutenberg 17.2 milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants