Stop sticky language tabs from overriding non-language tab choices - #2956
Merged
Conversation
The tab-language persistence script re-ran restore() after every DOM mutation, so on pages whose tab groups mix a saved language with other labels (Python / TypeScript / HTTP API, Command Line / Python), clicking a non-language tab mutated the DOM and triggered a restore that snapped the group straight back to the saved language, making those tabs unselectable. Two fixes: - Manual overrides win: a trusted click on a non-language tab marks its group as reader-overridden for the rest of the page view, and restore() skips overridden groups. Overrides are held in a WeakSet keyed by the group node, so they clear naturally when navigation replaces the DOM. - Restore only on navigation: the MutationObserver now re-applies the saved language only when location.pathname actually changed, instead of after every mutation burst. Verified locally with mint dev: HTTP API stays selected on /weave/guides/tracking/querying-calls, and the saved TypeScript preference still restores on SPA navigation to /weave/quickstart. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
HiveMind Sessions1 session · 21m · $5.59
View all sessions in HiveMind → Run |
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
dbrian57
marked this pull request as ready for review
July 23, 2026 18:05
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.
Problem
#2759 added cross-page persistence for the Python/TypeScript tab choice. But
restore()re-ran after every DOM mutation (via aMutationObservermeant to catch SPA route changes). Switching a tab is itself a DOM mutation, so on any page whose tab group mixes a saved language with other labels — e.g. Python / TypeScript / HTTP API on/weave/guides/tracking/querying-calls, or Command Line / Python / Python notebook on/models/quickstart— clicking a non-language tab triggered a restore ~80ms later that snapped the group right back to the saved language. Those tabs were effectively unselectable.Fix
Two complementary changes to
code-group-language-persist.js:restore()skips overridden groups for the rest of that page view. Overrides live in aWeakSetkeyed by the group's DOM node, so they clear naturally when navigation replaces the page content. Clicking a language tab in an overridden group un-marks it. Synthetic clicks dispatched byrestore()itself are ignored (isTrustedcheck), so they can never register as reader choices.MutationObservernow re-applies the saved language only whenlocation.pathnameactually changed, with the same hydration retry ladder as initial load.Verification (local
mint dev)/weave/guides/tracking/querying-calls(Python / TypeScript / HTTP API): picked TypeScript (preference saved), then clicked HTTP API — it stayed selected 2s later, well past all restore timers. Previously it reverted within ~80ms./weave/quickstart— the saved TypeScript preference was auto-restored there (Python is the default first tab).🤖 Generated with Claude Code