From 212c0dfd076e4e504de135b2b41647199feb3696 Mon Sep 17 00:00:00 2001 From: "Patrick H. Lauke" Date: Mon, 2 Jan 2023 05:54:46 +0000 Subject: [PATCH] Docs: Make theme switcher accessible (#37780) * Make theme switcher accessible * set an explicit `aria-label` to the switcher (as the `` is not sufficient, as it can be display:none'd and then the button has no accName) * make the theme buttons actual `aria-pressed` toggles * Dynamically update aria-label for theme switcher * Explicitly reset focus after activating theme * Use innerText for the constructed dynamic aria-label this way, if the text ever gets changed in the html, this will adapt appropriately * Tweak accessible name for the dropdown * Fixup * Use `textContent` instead of `innerText` --- site/layouts/partials/docs-navbar.html | 13 +++++++------ site/static/docs/5.3/assets/js/color-modes.js | 7 +++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/site/layouts/partials/docs-navbar.html b/site/layouts/partials/docs-navbar.html index 4b942a65e7..2795ec85b7 100644 --- a/site/layouts/partials/docs-navbar.html +++ b/site/layouts/partials/docs-navbar.html @@ -90,27 +90,28 @@ type="button" aria-expanded="false" data-bs-toggle="dropdown" - data-bs-display="static"> + data-bs-display="static" + aria-label="Toggle theme (auto)"> - Toggle theme + Toggle theme -