Merge stable into release-1.8#8498
Merged
fatih-acar merged 2 commits intorelease-1.8from Feb 27, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Merging stable into release-1.8 after merging pull request #8429.