mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Fix ARIA labels for all anchors with href="#"
; adds aria-pressed
information for toggles (#1262)
This follows up from #1259 and closes #1261. Basically, this PR accomplishes the two items discussed in the issue: 1. for all anchors that are *actually* buttons (i.e., have `href="#"`), I've replaced them with a semantic `<button>` - under the hood, I've made a `.btn-reset` class pulling out the reset from #1259, so there's no visual change 2. for anchors that are ["toggle buttons"](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#toggle_buttons) (the mobile menu nav, sidebar children/grandchildren toggles), I've added an `aria-pressed` property that is updated as the button is clicked I've also slightly modified some of the `aria-label`s to make them more consistent. Observe that we *shouldn't* update these as the button is clicked; screen readers use the `aria-pressed` property to add an annotation to each button. To test this, - the sidebar children and grandchildren can be done on the deploy preview: - open an arbitrary page; observe that the sidebar children/grandchildren dropdown ticks now have a proper `aria-label` and `aria-pressed`, as well as otherwise work as intended - toggle one of the buttons; observe the `aria-pressed` role changing as this is done - open a grandchild page; observe that the `aria-pressed` has a correct default wrt whether or not the page is active - the mobile menu can be done on the deploy preview; on a smaller viewport, observe the correct `aria-pressed` - two features require local changes to test: - the `site.search.button` needs to be enabled in the `_config.yml`. To test this, locally clone the repo, change the flag, and observe that the button still works as intended + has no visual regressions. - the collections feature is a bit more complicated. To test this, locally clone the repo, add an arbitrary collection and changes to `_config.yml`, and observe the same behaviour for the sidebar children/grandchildren above
This commit is contained in:
@@ -31,7 +31,7 @@ function initNav() {
|
||||
}
|
||||
if (target) {
|
||||
e.preventDefault();
|
||||
target.parentNode.classList.toggle('active');
|
||||
target.ariaPressed = target.parentNode.classList.toggle('active');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -45,9 +45,11 @@ function initNav() {
|
||||
if (menuButton.classList.toggle('nav-open')) {
|
||||
siteNav.classList.add('nav-open');
|
||||
mainHeader.classList.add('nav-open');
|
||||
menuButton.ariaPressed = true;
|
||||
} else {
|
||||
siteNav.classList.remove('nav-open');
|
||||
mainHeader.classList.remove('nav-open');
|
||||
menuButton.ariaPressed = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -491,8 +493,8 @@ jtd.onReady(function(){
|
||||
if (!window.isSecureContext) {
|
||||
console.log('Window does not have a secure context, therefore code clipboard copy functionality will not be available. For more details see https://web.dev/async-clipboard/#security-and-permissions');
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var codeBlocks = document.querySelectorAll('div.highlighter-rouge, div.listingblock > div.content, figure.highlight');
|
||||
|
||||
// note: the SVG svg-copied and svg-copy is only loaded as a Jekyll include if site.enable_copy_code_button is true; see _includes/icons/icons.html
|
||||
|
Reference in New Issue
Block a user