From d62c529b0278a9ac790b22f46f49004df71112ea Mon Sep 17 00:00:00 2001 From: Paul Nothaft Date: Sun, 10 May 2026 21:58:44 +0200 Subject: [PATCH] fix(create-event): branding-default theme survives eventTypes refetch The "apply recommended preset on event-type change" effect was firing on the initial mount AND every time the eventTypes API resolved (because availableEventTypes is recomputed when that query settles). The first fire matched the wedding default and clobbered the global Branding theme that the previous effect had just applied. Track the previous event_type in a ref and bail out when it hasn't actually changed. The Branding-default effect now wins on first paint, and the recommended-preset behaviour still kicks in when the user manually picks a different event type. Restores the green state of smoke spec 07 (#323-B regression). --- frontend/src/pages/admin/CreateEventPage.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/admin/CreateEventPage.tsx b/frontend/src/pages/admin/CreateEventPage.tsx index cf36ed86..3ad86283 100644 --- a/frontend/src/pages/admin/CreateEventPage.tsx +++ b/frontend/src/pages/admin/CreateEventPage.tsx @@ -283,11 +283,23 @@ export const CreateEventPage: React.FC = () => { })); }, [settings]); - // Update theme when event type changes — but only when the event type has - // an explicit recommended preset. Skip the generic 'default' so the global - // Branding theme isn't clobbered by Classic Grid for event types like - // "Other" (#323). + // Update theme when the user actively changes the event type — but only + // when the new type has an explicit recommended preset. Skips both the + // generic 'default' (so types like "Other" don't clobber the global + // Branding theme with Classic Grid) and the very first render (so the + // wedding default doesn't out-race the Branding-default effect above + // when eventTypes resolves AFTER settings — #323-B / smoke spec 07). + const prevEventTypeRef = useRef(null); useEffect(() => { + const prev = prevEventTypeRef.current; + prevEventTypeRef.current = formData.event_type; + // First render: just record the initial value and let the + // Branding-default effect own the theme. Without this guard the + // initial-mount fire of this effect (and any later eventTypes + // refetch that swaps `availableEventTypes` identity) would + // overwrite the Branding theme with the wedding preset. + if (prev === null || prev === formData.event_type) return; + const selectedType = availableEventTypes.find(t => t.value === formData.event_type); const recommendedPreset = selectedType?.theme_preset;