diff --git a/src/web/styles.ts b/src/web/styles.ts index 5ccb073fb1..183c8068ad 100644 --- a/src/web/styles.ts +++ b/src/web/styles.ts @@ -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; diff --git a/tests/dsh-settings-ui.test.ts b/tests/dsh-settings-ui.test.ts index 5c55c28055..6c8ac47268 100644 --- a/tests/dsh-settings-ui.test.ts +++ b/tests/dsh-settings-ui.test.ts @@ -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 + // (#/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", + ); +});