Repository navigation
Conversation
…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
There was a problem hiding this comment.
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
|
I had something similar in the beginning, and would love to avoid using internal API. 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? |
|
Ah, I see. Then if @schuellerf says it's still relevant today, we can go with this version, fine by me! 🚀 |
|
The original commit introducing this workaround mentioned NotebookLM (nowadays Gemini Notebook) being affected by this. |
|
What if we redesigned this so that examples are always visible, one under the other, without tabbing? |
|
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. |
|
@achilleas-k I think the "Tabs" are just a default feature of docusaurus, so we used it… |
Since the upgrade to Docusaurus 3.10 (bd774b8),
<Tabs>no longer passes ahiddenprop to its children; the original TabItem instead derives its selection state from its ownvalueprop and the tabs context.Our wrapper stripped
valuebefore passing props on, so no TabItem was ever considered selected and all blueprint examples were hidden.Derive
hiddenvia useTabs() instead, and always pass the selected value to the original TabItem so it never renders thehiddenattribute.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