feat: synchronize CodeGroup tab selection across page and persist preference #342
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.
Hey there, this is also another feature we are currently using on Scenario that I think should benefit other vocs user:
https://scenario.langwatch.ai/
===
Adds state management to CodeGroup component to synchronize tab selection across all code groups on the same page and persist user preference to localStorage.
When a user selects a language tab (e.g., TypeScript, JavaScript), all other code groups on the page automatically switch to the same language, and the preference is saved. When the user returns to the documentation, their preferred language is automatically selected.
Key features:
This significantly improves UX for users who consistently prefer one language, eliminating the need to manually switch tabs on every code example.
It also allows listening to external components changing the global language, e.g. this select we have on top: