Enhancement: Improve accessibility of site header #3130
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.
Description
Note
Please note that this Pull Request is currently in progress.
Currently, the accessibility of the site header is lacking. For instance, users cannot navigate to the toggle button via the keyboard or change its state. Additionally, while the toggle uses a
<label>element to allow toggling the drop-down without JavaScript, which is a commendable approach, the element is not marked as a button, despite functioning as one.This Pull Request introduces a new file,
header.js, which adds support for interacting with the drop-down toggle via the keyboard, as well as settingaria-pressed,tabindex, androleattributes. Here's a breakdown for each attribute as to why they are added to the element via JavaScript:aria-pressed- Its value necessarily depends on being updated via JavaScript, which, without it, may lead to confusion for users, as the value of the attribute wouldn't match the toggled state of the drop-down.tabindex- Setting the attribute's value to0allows users to navigate via the keyboard to the drop-down toggle. However, without JavaScript, there is no means by which the user can toggle the visibility of the drop-down. As such, the attribute should only be added via JavaScript to avoid any confusion.role- Setting the attribute's value to"button"signals to assistive technology that the element is a button. However, on its own, such an attribute doesn't add any additional functionality to the<label>element that native<button>elements have since this functionality must be added manually via JavaScript. As such, the attribute should only be added via JavaScript to avoid any confusion.Related issues
Closes #3115.
Role
Individual not affiliated with any project relevant to this PR.
Timeline
There’s no immediate deadline, so feel free to review this PR whenever you can.
Signoff
Please sign off your individual commits or whole pull request.