Tabs: cleanup and improvements #56224
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
A few small updates to the
Tabs
component family:useTabContext()
consistently, instead of sometimes usinguseContext()
Tabs.Context
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 aTabs.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.