Skip to content

theme/TabItem: fix examples content not rendering after Docusaurus up… - #224

Closed
lfauster wants to merge 1 commit into
osbuild:mainfrom
lfauster:fix-blueprint-examples
Closed

lfauster wants to merge 1 commit into
osbuild:mainfrom
lfauster:fix-blueprint-examples

Conversation

@lfauster

@lfauster lfauster commented Nov 23, 2026 •

Copy link
Copy Markdown

Since the upgrade to Docusaurus 3.10 (bd774b8), <Tabs> no longer passes a hidden prop to its children; the original TabItem instead derives its selection state from its own value prop and the tabs context.

Our wrapper stripped value before passing props on, so no TabItem was ever considered selected and all blueprint examples were hidden.

Derive hidden via useTabs() instead, and always pass the selected value to the original TabItem so it never renders the hidden attribute.

useTabs() is an internal Docusaurus API, but TabItem is not marked as safe to swizzle anyway [1], so this needs re-checking on upgrades either way.

Fixes #223

[1] https://docusaurus.io/docs/swizzling

…grade

Since the upgrade to Docusaurus 3.10 (bd774b8), <Tabs> no longer passes
a `hidden` prop to its children; the original TabItem instead derives
its selection state from its own `value` prop and the tabs context.

Our wrapper stripped `value` before passing props on, so no TabItem was
ever considered selected and all blueprint examples were hidden.

Derive `hidden` via useTabs() instead, and always pass the selected
value to the original TabItem so it never renders the `hidden`
attribute.

useTabs() is an internal Docusaurus API, but TabItem is not marked as
safe to swizzle anyway [1], so this needs re-checking on upgrades either way.

[1] https://docusaurus.io/docs/swizzling
@lfauster
lfauster requested a review from a team as a code owner November 23, 2026 18:57

@ksiekl ksiekl left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks! This is a good workaround to keep the logic as it was. However, I noticed the comment above the wrapper

Wrapper for TabItem to hide the tab content visually but keep it in the DOM for scrapers

If that is the sole reason we have the wrapper, then we can just leave the visibility management on Tabs and TabItem. They render inactive panels with the HTML hidden attribute (unless they are lazy) and keep their children in DOM, so we would achieve that same result and we don't need to bring in the additional dependency on internal API.

What do you think? I'd actually prefer that approach if you're not opposed to it 😌

I imagine something very simple, like:

  export default function TabItemWrapper(props: Props): JSX.Element {
    const getContextLabel = (tabValue: string) => {
      if (tabValue === 'on-premises') return 'On premises example:';
      if (tabValue === 'hosted') return 'Hosted example:';
      if (tabValue === 'bootc') return 'Bootc example:';
      return `${tabValue} example:`;
    };

    return (
      <TabItem {...props}>
        <div className={styles.contextLabel}>
          {getContextLabel(props.value)}
        </div>
        {props.children}
      </TabItem>
    );
  }

Then we could also remove hiddenTabItem from styles

@lfauster

Copy link
Copy Markdown
Author

I had something similar in the beginning, and would love to avoid using internal API.
However, the comment you are referring to might not tell the full story. The original commit (e260634) introducing the wrapper describes the problem a bit more in detail and mentions that hidden attributes must be avoided.
The approach you outlined does fix the rendering issue, but does lead to hidden content.

However I don't know if the problem mentioned in the original commit is still relevant today, or what the easiest way to verify it is. Maybe @schuellerf knows?

@ksiekl

ksiekl commented Nov 24, 2026

Copy link
Copy Markdown

Ah, I see. Then if @schuellerf says it's still relevant today, we can go with this version, fine by me! 🚀

@lfauster

lfauster commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

The original commit introducing this workaround mentioned NotebookLM (nowadays Gemini Notebook) being affected by this.
I quickly tried with the currently published version of the blueprint reference - which has hidden set for all examples - and looks like Notebook is able to see and process the hidden examples.

@achilleas-k

Copy link
Copy Markdown
Member

What if we redesigned this so that examples are always visible, one under the other, without tabbing?

@achilleas-k

achilleas-k commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Could even go further (later) and move examples to a separate page. We keep the reference "clean" and link to the examples page accordingly. It would even make it possible to have multiple examples for each option.

@schuellerf

Copy link
Copy Markdown
Contributor

@achilleas-k I think the "Tabs" are just a default feature of docusaurus, so we used it…
Not sure if separate pages are better for maintainability and scrapers although I agree this page is pretty overloaded.
Let's brainstorm other solutions in some followup PR.

@schuellerf

Copy link
Copy Markdown
Contributor

The current scrapers (Gemini Notebook, Perplexity Projects…) seem to be fine now with "hidden" information, so we'll go with #225 for now.
Thanks @lfauster for pushing this topic!

@schuellerf schuellerf closed this Nov 24, 2026
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.

Can't see any code examples in blueprint references

4 participants