Repository navigation
Fix light/dark toggle shown when the dark brand file is ignored - #15132
Merged
Merged
Conversation
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.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #15101, a brand file that holds only comments is ignored with a warning. When that file is the
darkone of a light/dark brand, the HTML page still got the color-scheme toggle with no dark stylesheet to switch to. With onlybrand: {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()insrc/format/html/format-html-info.ts, which reads the key order oftheme:andbrand:in the metadata. Once the dark file is dropped, thebrand:metadata still listsdark:, 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, sotheme: {light, dark}keeps its toggle when the dark brand file is ignored.darkModeDefaultMetadata()keeps its behavior, asrender-contexts.tscalls 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):
AI-assisted PR
llm-docs/html-dark-mode-architecture.mdNote: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.