Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/web/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ export const WEB_STYLES = String.raw`
framed document's prefers-color-scheme. An explicit pin outranks the OS
signal, so the media query below is narrowed to documents WITHOUT one;
the pinned palette repeats the same list (CSS cannot share declarations
across media boundaries — keep the two lists in sync). */
across media boundaries — keep the two lists in sync).
#6587: each dark palette declares color-scheme: dark. The UA paints native
control chrome (a select's option popup, checkbox/radio glyphs, scrollbars)
from color-scheme rather than from the CSS vars, so the declaration keeps
those controls on the dark ground the palette establishes. */
@media (prefers-color-scheme: dark) {
:root:not([data-theme]) {
color-scheme: dark;
--bg: #0d1117;
--bg-elev: #161b22;
--bg-muted: #1c2129;
Expand Down
30 changes: 30 additions & 0 deletions tests/dsh-settings-ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2260,3 +2260,33 @@ test("#4406: the Context tab marks the conversation scroll container and hides t
m.runCleanups();
assert.equal(scrollAttrs.has("data-bili-surface"), false, "leaving the tab drops the marker");
});

test("#6587: both dark palettes bind color-scheme so native controls follow the theme", () => {
// `color-scheme` is what the UA paints native control chrome from: a
// <select>'s option popup, checkbox/radio glyphs, scrollbars. The base
// :root carries `light dark` (#2473, canvas/ground coupling), but the
// BASE value resolves to `light` whenever the OS asks for neither scheme,
// so each dark palette rebinds it to dark — otherwise the compress
// prompt-pack <select> (#/config -> compress.promptPack) pops a white
// option list over the dark settings face while the page itself is dark.
// Scope the read: the base :root also declares `color-scheme: light dark`,
// so a bare includes() passes even with both dark blocks stripped.
const styles = fs.readFileSync(new URL("../src/web/styles.ts", import.meta.url), "utf8").replace(/\r\n/g, "\n");
const decls = (open: string): string[] => {
const i = styles.indexOf(open);
assert.ok(i >= 0, `${open} present`);
return styles
.slice(i + open.length, styles.indexOf("}", i))
.split("\n")
.map((l) => l.trim().replace(/;\s*$/, ""))
.filter((l) => l !== "");
};
assert.ok(
decls(':root[data-theme="dark"] {').includes("color-scheme: dark"),
"the pinned dark palette binds color-scheme: dark",
);
assert.ok(
decls(":root:not([data-theme]) {").includes("color-scheme: dark"),
"the OS-driven dark palette binds color-scheme: dark for native controls",
);
});
Loading