Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/v4/app/(app)/create/components/theme-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export function ThemePicker({
[params.theme]
)

React.useEffect(() => {
if (!currentTheme && themes.length > 0) {
setParams({ theme: themes[0].name })
}
}, [currentTheme, themes, setParams])
// NOTE: The useEffect that called setParams({ theme: themes[0].name }) when
// currentTheme was undefined has been removed. Theme validation and fallback
// is already handled by normalizeDesignSystemParams in search-params.ts.
// The effect was causing a second racing setParams call after baseColor
// changes, which produced the flickering/selection-reset bug (#10910).

return (
<div className="group/picker relative">
Expand Down
6 changes: 5 additions & 1 deletion apps/v4/app/(app)/create/lib/search-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,14 @@ function resolvePresetParams(
// Wraps nuqs useQueryStates with transparent preset encoding/decoding.
// - Reads: if ?preset=CODE is in the URL, decodes it and returns individual values.
// - Writes: when design system params are set, encodes them into a preset code.
//
// Default options use shallow: true so picker selections do not trigger a full
// Next.js server navigation. This prevents the customizer panel from flickering
// or resetting while the URL update propagates (#10910).
export function useDesignSystemSearchParams(options: Options = {}) {
const searchParams = useSearchParams()
const [rawParams, rawSetParams] = useQueryStates(designSystemSearchParams, {
shallow: false,
shallow: true,
history: "push",
...options,
})
Expand Down
Loading