Skip to content

fix(config): don't shadow env-provided font CSS with Nunito defaults#125

Open
aymericcousaert wants to merge 1 commit into
masterfrom
fix/respect-env-font-overrides
Open

fix(config): don't shadow env-provided font CSS with Nunito defaults#125
aymericcousaert wants to merge 1 commit into
masterfrom
fix/respect-env-font-overrides

Conversation

@aymericcousaert
Copy link
Copy Markdown
Collaborator

Summary

When the operator provides a font configuration via env (typically THEME_BODY_FONT_FAMILY_CSS or THEME_BODY_FONT_FAMILY), the lib's Nunito defaults from @data-fair/lib-common-types still merged in under the override. Because the env value lives in themeOverrides and the lib default lives in defaultTheme, and only the env CSS was provided, the final config ended up shipping both: the lib's Nunito @font-face block prepended in front of the operator's CSS rules, plus bodyFontFamily: Nunito silently overriding the (unset) operator font name.

Net effect: operators who wired up THEME_BODY_FONT_FAMILY_CSS via their installer (e.g. MyDataCatalogue's installer ships an Inter CSS block pointing at /studio/assets/fonts/inter/...) saw _public.js advertise bodyFontFamily='Nunito' anyway, and the @font-face declarations from the lib's Nunito shadowed the operator's Inter rules.

When the operator provides any font config, drop the matching lib defaults before merging so the env-provided values win cleanly. The no-env path is unchanged — Nunito is still the SD default when nothing else is set.

Test plan

New unit spec tests/features/config-theme-font-merge.unit.spec.ts asserts the three cases:

  • no env → Nunito stays
  • env CSS provided → lib Nunito stripped, env CSS wins
  • env name provided → lib Nunito stripped, env name wins

When the operator provides a font configuration via env (typically
THEME_BODY_FONT_FAMILY_CSS or THEME_BODY_FONT_FAMILY), the lib's Nunito
defaults from @data-fair/lib-common-types still merged in under the
override. Because the env value lives in 'themeOverrides' and the lib
default lives in 'defaultTheme', and only the env CSS was provided, the
final config ended up shipping both: the lib's Nunito @font-face block
prepended in front of the operator's CSS rules, plus 'bodyFontFamily:
Nunito' silently overriding the (unset) operator font name.

Net effect: operators who wired up THEME_BODY_FONT_FAMILY_CSS via their
installer (e.g. MyDataCatalogue's installer ships an Inter CSS block
pointing at /studio/assets/fonts/inter/...) saw _public.js advertise
bodyFontFamily='Nunito' anyway, and the @font-face declarations from
the lib's Nunito shadowed the operator's Inter rules.

When the operator provides any font config, drop the matching lib
defaults before merging so the env-provided values win cleanly. The
no-env path is unchanged — Nunito is still the SD default when nothing
else is set.

Tested via a new unit spec (config-theme-font-merge.unit.spec.ts) that
asserts the three cases:
- no env → Nunito stays
- env CSS provided → lib Nunito stripped, env CSS wins
- env name provided → lib Nunito stripped, env name wins
@github-actions github-actions Bot added the fix label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant