From 360c51db6f2e363d8f5ffb6dd4486c5232bcb3f4 Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Fri, 17 Jul 2026 11:50:55 -0700 Subject: [PATCH 1/4] Make dark/light mode toggle an accessible switch (#13463) The toggle was an with a CSS-drawn icon: no accessible name (axe link-name, WCAG 2.4.4/4.1.2), link role for a button-like control (Space did not activate it), and mode state conveyed only by a background-image swap that never reaches the accessibility tree. Now a From ab9a900edd0efb02d136a600c91dbf7906872146 Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Fri, 17 Jul 2026 11:51:47 -0700 Subject: [PATCH 2/4] Add smoke tests for color-scheme toggle switch (#13463) Positive: the toggle renders as button[role=switch][aria-checked] with a localized aria-label on websites (static), multi-page dashboards (static), and plain documents (script-text regex, since the fallback toggle is injected at DOMContentLoaded). Guard rails: light-only documents still emit no toggle markup at all, and the reader-mode toggle and navbar tool links keep their existing anchor shape. All fail against the pre-fix source except the light-only guard, which passes on both (verified by stashing the fix). --- .../color-scheme-toggle-dashboard.qmd | 25 +++++++++++++++++++ .../color-scheme-toggle-fallback.qmd | 24 ++++++++++++++++++ .../dark-mode/no-toggle-without-dark.qmd | 15 +++++++++++ .../website/color-scheme-toggle/.gitignore | 5 ++++ .../website/color-scheme-toggle/_quarto.yml | 20 +++++++++++++++ .../website/color-scheme-toggle/index.qmd | 16 ++++++++++++ 6 files changed, 105 insertions(+) create mode 100644 tests/docs/smoke-all/dark-mode/color-scheme-toggle-dashboard.qmd create mode 100644 tests/docs/smoke-all/dark-mode/color-scheme-toggle-fallback.qmd create mode 100644 tests/docs/smoke-all/dark-mode/no-toggle-without-dark.qmd create mode 100644 tests/docs/smoke-all/website/color-scheme-toggle/.gitignore create mode 100644 tests/docs/smoke-all/website/color-scheme-toggle/_quarto.yml create mode 100644 tests/docs/smoke-all/website/color-scheme-toggle/index.qmd diff --git a/tests/docs/smoke-all/dark-mode/color-scheme-toggle-dashboard.qmd b/tests/docs/smoke-all/dark-mode/color-scheme-toggle-dashboard.qmd new file mode 100644 index 00000000000..571a91be8f8 --- /dev/null +++ b/tests/docs/smoke-all/dark-mode/color-scheme-toggle-dashboard.qmd @@ -0,0 +1,25 @@ +--- +title: "Dashboard color-scheme toggle is a named switch (#13463)" +format: + dashboard: + theme: + light: flatly + dark: darkly +_quarto: + tests: + dashboard: + ensureHtmlElements: + - + - 'button.quarto-color-scheme-toggle[type="button"][role="switch"][aria-checked="false"][aria-label="Toggle dark mode"]' + - + - 'a.quarto-color-scheme-toggle' +--- + +# Page A + +Multi-page so `processPages()` injects the navbar toggle (single-page +dashboards get the JS-injected fallback toggle instead). + +# Page B + +Second page. diff --git a/tests/docs/smoke-all/dark-mode/color-scheme-toggle-fallback.qmd b/tests/docs/smoke-all/dark-mode/color-scheme-toggle-fallback.qmd new file mode 100644 index 00000000000..6c78604e3bf --- /dev/null +++ b/tests/docs/smoke-all/dark-mode/color-scheme-toggle-fallback.qmd @@ -0,0 +1,24 @@ +--- +title: "Fallback color-scheme toggle is a named switch (#13463)" +format: + html: + theme: + light: flatly + dark: darkly +_quarto: + tests: + html: + ensureFileRegexMatches: + - + - "createElement\\('button'\\)" + - 'setAttribute\("role", "switch"\)' + - 'setAttribute\("aria-label"' + - 'setAttribute\("aria-checked", alternate' + - + - 'a\.href = ""' +--- + +The toggle on a plain document (no navbar) is injected by the after-body +script at `DOMContentLoaded`, so these assertions check the script text: the +fallback creates a `button` switch with a name, `setColorSchemeToggle()` keeps +`aria-checked` in sync, and the old nameless-anchor creation is gone. diff --git a/tests/docs/smoke-all/dark-mode/no-toggle-without-dark.qmd b/tests/docs/smoke-all/dark-mode/no-toggle-without-dark.qmd new file mode 100644 index 00000000000..30f59ae6e57 --- /dev/null +++ b/tests/docs/smoke-all/dark-mode/no-toggle-without-dark.qmd @@ -0,0 +1,15 @@ +--- +title: "No color-scheme toggle without a dark theme" +format: + html: + theme: flatly +_quarto: + tests: + html: + ensureFileRegexMatches: + - [] + - + - 'quarto-color-scheme-toggle' +--- + +A light-only document must not emit any toggle markup or toggle script. diff --git a/tests/docs/smoke-all/website/color-scheme-toggle/.gitignore b/tests/docs/smoke-all/website/color-scheme-toggle/.gitignore new file mode 100644 index 00000000000..0b3bf772477 --- /dev/null +++ b/tests/docs/smoke-all/website/color-scheme-toggle/.gitignore @@ -0,0 +1,5 @@ +/.quarto/ +*.html +*.json +site_libs/ +**/*.quarto_ipynb diff --git a/tests/docs/smoke-all/website/color-scheme-toggle/_quarto.yml b/tests/docs/smoke-all/website/color-scheme-toggle/_quarto.yml new file mode 100644 index 00000000000..de63c8051d2 --- /dev/null +++ b/tests/docs/smoke-all/website/color-scheme-toggle/_quarto.yml @@ -0,0 +1,20 @@ +project: + type: website + output-dir: . + +website: + title: "Website" + reader-mode: true + navbar: + left: + - href: index.qmd + text: Home + tools: + - icon: github + href: https://github.com/quarto-dev/quarto-cli + +format: + html: + theme: + light: flatly + dark: darkly diff --git a/tests/docs/smoke-all/website/color-scheme-toggle/index.qmd b/tests/docs/smoke-all/website/color-scheme-toggle/index.qmd new file mode 100644 index 00000000000..377b071a051 --- /dev/null +++ b/tests/docs/smoke-all/website/color-scheme-toggle/index.qmd @@ -0,0 +1,16 @@ +--- +title: "Website" +_quarto: + tests: + html: + ensureHtmlElements: + - + - 'button.quarto-color-scheme-toggle[type="button"][role="switch"][aria-checked="false"][aria-label="Toggle dark mode"][title="Toggle dark mode"]' + - 'a.quarto-reader-toggle[title]' + - 'a.quarto-navigation-tool[href="https://github.com/quarto-dev/quarto-cli"]' + - + - 'a.quarto-color-scheme-toggle' +--- + +The navbar color-scheme toggle is a named switch (#13463); the reader-mode +toggle and navbar tool links keep their existing shape. From 0f3c1ad769f9efd5e14b12004f54d9b7919f6174 Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Wed, 29 Jul 2026 14:08:06 -0700 Subject: [PATCH 3/4] Update Playwright specs for color-scheme toggle button markup (#13463) The toggle is now a