From 35f5b86d0f6a56627aac2abfe5228b5935709b08 Mon Sep 17 00:00:00 2001 From: Luca <102960244+Luca-Timo@users.noreply.github.com> Date: Mon, 11 May 2026 11:50:09 +0200 Subject: [PATCH] fix(theme): 'Same as body' heading font no longer inherits stale value --- frontend/src/contexts/ThemeContext.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/contexts/ThemeContext.tsx b/frontend/src/contexts/ThemeContext.tsx index 3b9ddcdc..af058d9d 100644 --- a/frontend/src/contexts/ThemeContext.tsx +++ b/frontend/src/contexts/ThemeContext.tsx @@ -186,9 +186,18 @@ export const ThemeProvider: React.FC = ({ void loadFontForFamily(themeConfig.fontFamily); } - if (themeConfig.headingFontFamily) { - root.style.setProperty('--heading-font-family', themeConfig.headingFontFamily); - void loadFontForFamily(themeConfig.headingFontFamily); + // "Same as body" is stored as headingFontFamily='' — in that case + // mirror the body family so a stale --heading-font-family (e.g. + // from a previously-visited gallery with a serif heading theme) + // doesn't bleed into pages that picked the matched-fonts option. + // Without this fall-through the CSS variable retained the last + // explicit value across theme switches, which is why the customer + // profile and admin login rendered serif headings even though the + // active theme had "Same as body" selected. + const effectiveHeadingFont = themeConfig.headingFontFamily || themeConfig.fontFamily; + if (effectiveHeadingFont) { + root.style.setProperty('--heading-font-family', effectiveHeadingFont); + void loadFontForFamily(effectiveHeadingFont); } if (themeConfig.borderRadius) {