Skip to content

Conversation

@abdulalim110
Copy link

Motivation

Currently, the <Tabs> component enforces strict validation that throws a runtime error (Bad <Tabs> child) if any direct child is not strictly a <TabItem>.

This restriction prevents developers from using Component Composition (wrapping <TabItem> inside other components to abstract logic or styles), even if the wrapper correctly passes the required props.

This PR removes the strict throw new Error validation in sanitizeTabsChildren.

Benefits:

  1. Enables Composition: Developers can now wrap TabItem components (e.g., <MyCustomTab value="x">).

  2. Graceful Failure: If a user/developer forgets to pass props (invalid usage), the application no longer crashes. Instead, it renders an empty tab, providing a visual cue to fix the code without breaking the entire development experience.

Test Plan

I verified the fix using a wrapper component that abstracts the <TabItem>.

Test Code (Simulating Component Composition):

export const Local = ({ children }) => (
  <TabItem value="local" label="Local Installation">
    {children}
  </TabItem>
);

<InstallationGroup>
  <Local>
    Test Local 
  </Local>
</InstallationGroup>

Verification

Before (Current Behavior) After (This Fix)
Crash / Fatal Error
The app crashes because the wrapper does not expose the value prop to the parent <Tabs>.
Graceful Fallback
The app renders the content ("Test Local") without crashing. The tab button renders (empty/fallback) instead of breaking the page.
before-relax-validation after-relax-validation

Related issues/PRs

Fixes #11672

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Feb 9, 2026
@netlify
Copy link

netlify bot commented Feb 9, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 12a87f4
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6989f5084712b4000855df58
😎 Deploy Preview https://deploy-preview-11728--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot extend Tabs and TabItem components

1 participant