Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Selected framework in Code component #12496

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gkettani
Copy link

☕️ Reasoning

The Code component currently uses the Tabs component from the Nextra UI library to display different code examples for various frameworks. The Tabs component achieves synchronization across all instances by storing the selected tab's index in local storage. However, relying on an index introduces limitations when the tabs differ in content or order between components.

This PR refactors the Code component to handle tab synchronization and local storage management directly, decoupling this logic from the Tabs component. Instead of storing an index, the name of the framework is stored in local storage. This implementation:

  1. Stores the framework name in local storage instead of the index.
  2. Checks whether the stored framework name is valid for the current context.
  3. Displays the valid framework's tab or defaults to the first tab if no valid value is found.
  4. Synchronizes tabs across components using a StorageEvent, ensuring updates are propagated immediately.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Fixes: #12451

📌 Resources

Copy link

vercel bot commented Jan 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ❌ Failed (Inspect) Jan 12, 2025 0:51am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Jan 12, 2025 0:51am

Copy link

vercel bot commented Jan 12, 2025

@gkettani is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

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.

Selected framework is not consistent across multiple Code components in the page.
1 participant