Skip to content

Merge stable into release-1.8#8498

Merged
fatih-acar merged 2 commits intorelease-1.8from
stable
Feb 27, 2026
Merged

Merge stable into release-1.8#8498
fatih-acar merged 2 commits intorelease-1.8from
stable

Conversation

@infrahub-github-bot-app
Copy link
Contributor

Merging stable into release-1.8 after merging pull request #8429.

This allows sharing anchored URLs pointing to non-default tabs.

Signed-off-by: Fatih Acar <fatih@opsmill.com>
However, shared links with query parameters (e.g., ?method=graphql) require visiting the page twice before the correct tab is shown.

Root cause: Docusaurus's SSG hydration forces search: '' in the server snapshot (useHistorySelector in historyUtils.js) to avoid React hydration mismatches. The useTabs hook initializes state with defaultValue (the first tab), then syncs the query string value only AFTER the initial render via useIsomorphicLayoutEffect. This means:

Pre-rendered HTML always shows the default tab
On first client render, useState initializes with defaultValue, not the query string
The query string value is applied after mount, but any hash-anchor scroll has already failed because the target content was hidden

Fix: Swizzle Tabs component with a --wrap wrapper
Create docs/src/theme/Tabs/index.tsx — a thin wrapper around the original Tabs that:

Reads the query string from window.location.search on the client
Passes the matching value as defaultValue to the original Tabs component (so useState initializes correctly on the client-side mount)
After hydration, re-scrolls to hash anchors (since the correct tab is now visible)

Why this works
Docusaurus's Tabs component uses key={String(isBrowser)} which causes a full remount after hydration. On the server/hydration pass, isBrowser=false so our wrapper passes the original defaultValue. After hydration, React remounts with isBrowser=true, our wrapper reads the query string from window.location.search, and the original Tabs receives the correct defaultValue for its useState initializer.
The --wrap swizzle pattern is Docusaurus's official extension mechanism — safe across upgrades.

Signed-off-by: Fatih Acar <fatih@opsmill.com>
@infrahub-github-bot-app infrahub-github-bot-app bot requested review from a team as code owners February 27, 2026 12:17
@fatih-acar fatih-acar merged commit 4d37a13 into release-1.8 Feb 27, 2026
40 checks passed
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.

1 participant