fix(create): left-panel selections flicker and do not stay selected#10930
Open
ShauryaaSharma wants to merge 1 commit into
Open
fix(create): left-panel selections flicker and do not stay selected#10930ShauryaaSharma wants to merge 1 commit into
ShauryaaSharma wants to merge 1 commit into
Conversation
Contributor
|
@ShauryaaSharma is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
… routing and removing racing setParams effect
b3563fb to
9ad3022
Compare
2 tasks
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.
Fixes #10910
Problem
On the
/createpage, selecting any option from the left-side configurationpanel (Base Color, Theme, Style, Font, Radius, etc.) would flicker and not
stay selected. The selection would briefly appear then reset, making the
customizer unusable.
Root Cause
Two compounding issues:
1. Non-shallow routing on every selection
useDesignSystemSearchParamsdefaulted toshallow: false, which triggereda full Next.js server navigation on every picker click. This caused the page
to re-suspend mid-render, visually resetting the panel state while the URL
update propagated.
2. Racing
setParamscall inThemePickerThemePickerhad auseEffectthat firedsetParams({ theme: themes[0].name })whenever
currentThemewas undefined. After abaseColorchange, there is abrief render window where
currentThemeappears undefined — causing a secondcompeting
setParamscall that raced against the first and produced theback-and-forth oscillation.
Fix
search-params.ts— changed default toshallow: trueinuseDesignSystemSearchParams. This matches howDesignSystemProvideralreadycalls it and prevents unnecessary server navigations on picker selections.
theme-picker.tsx— removed the redundantuseEffect. Theme validationand fallback is already handled authoritatively by
normalizeDesignSystemParamsin
search-params.ts, so the effect was never needed and only introduced a race condition.Testing
Tested on
http://localhost:4000/create?template=startacross all browsers:all hold selection without flickering
?preset=CODEformat and selection persists on reload