Skip to content

Fix light/dark toggle shown when the dark brand file is ignored - #15132

Merged
cderv merged 3 commits into
mainfrom
fix/light-dark-toggle-ignored-dark-brand
Oct 20, 2026
Merged

cderv merged 3 commits into
mainfrom
fix/light-dark-toggle-ignored-dark-brand

Conversation

@cderv

@cderv cderv commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Since #15101, a brand file that holds only comments is ignored with a warning. When that file is the dark one of a light/dark brand, the HTML page still got the color-scheme toggle with no dark stylesheet to switch to. With only brand: {dark: ...}, the page also started in dark mode (body.quarto-dark) with the light styles.

Root cause

Whether a page has a dark mode comes from darkModeDefault() in src/format/html/format-html-info.ts, which reads the key order of theme: and brand: in the metadata. Once the dark file is dropped, the brand: metadata still lists dark:, so the check reports a dark mode the loaded brand does not have. The same predicate gates the website navbar toggle, dashboards, giscus and the brand Sass defaults.

Fix

brand: key order now counts only when a dark brand was actually loaded (format.render.brand.dark). theme: key order is still checked first, so theme: {light, dark} keeps its toggle when the dark brand file is ignored. darkModeDefaultMetadata() keeps its behavior, as render-contexts.ts calls it before the brand is loaded.

Each new smoke-all document has its own comment-only fixture. The warning goes through warnOnce, so documents sharing one file in the same test run would see it only once.

Fixes #15131

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone, llm-docs/html-dark-mode-architecture.md
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

cderv added 3 commits October 20, 2026 16:44
A `brand: {dark: ...}` file holding only comments is dropped with a
warning, but the raw `brand:` metadata still lists `dark:`. The key-order
check in `darkModeDefault` read that metadata, so the page got a color-scheme
toggle, the toggle script and `body.quarto-dark` with no dark styles to
switch to.

Honour `brand:` key order only when a dark brand was actually loaded
(`format.render.brand?.dark`). `theme:` key order is unchanged and still
wins, so an explicit `theme: {light, dark}` keeps its toggle.
`darkModeDefaultMetadata` behaves as before: it runs before the brand is
loaded.
Update the dark mode architecture doc for the new `darkModeDefault`
inputs and add a Traps row for a dark brand file that is ignored.
The empty-brand warning goes through `warnOnce`, which remembers a
message for the rest of the process. Smoke-all renders every document of
a run in one process, so when the three dark-mode docs shared
`comment-only-dark-brand.yml` only the first render printed the warning
and the other two failed their `printsMessage` check, depending on
render order.

A distinct fixture path per document keeps the warning check in each
one, which is what shows the dark file was actually ignored.
@posit-snyk-bot

posit-snyk-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv
cderv merged commit 1836028 into main Oct 20, 2026
51 checks passed
@cderv
cderv deleted the fix/light-dark-toggle-ignored-dark-brand branch October 20, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Light/dark toggle shown without dark stylesheet when the dark brand file holds only comments

2 participants