a11y: make theme-switcher dropdown keyboard-accessible#541
Open
xpoes123 wants to merge 1 commit into
Open
Conversation
Convert href-less anchor dropdown items to buttons and add aria-haspopup to the toggle.
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.
The theme-switcher dropdown items in
client/ssi/nav.htmlwere bare<a>elements with nohref, making them unreachable by keyboard navigation. This converts them to native buttons and correctly advertises the popup role to assistive technologies.Problem
In
client/ssi/nav.html, the Light / Night / Auto theme options were<a class="dropdown-item ...">elements with nohref. Without anhref, anchor elements are not in the tab order and cannot be activated with Enter or Space. Users navigating by keyboard or using assistive technologies could not change the site theme.Additionally, the
#bd-themetoggle button was missingaria-haspopup, so screen readers received no indication that activating it opens a menu.Changes
<a>elements to<button type="button" class="dropdown-item ...">, which are natively focusable and keyboard-operable.aria-haspopup="menu"to the#bd-themetoggle button.Risk & testing
Bootstrap's
querySelectorAll('[data-bs-theme-value]')selector and plainclicklisteners in the theme-switching script work identically on buttons and anchors, so there is no functional change. Visual appearance is unchanged — Bootstrap'sdropdown-itemstyles apply equally to<button>elements. Onlyclient/ssi/nav.htmlis modified.