mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-04-09 21:41:23 -06:00
Add tabindex=0
to all code blocks
Note: this is a bit hacky. Ideally, I'd like to do this at the markdown level, since this doesn't serve folks who have JS disabled (among many other things). Also, curious to see how this interacts with custom highlighters; needs some more testing!
This commit is contained in:
parent
ce32212026
commit
b1e3394593
@ -566,8 +566,17 @@ jtd.onReady(function(){
|
||||
{%- endif %}
|
||||
});
|
||||
|
||||
// Copy button on code
|
||||
// Accessibility: set tabindex=0 on each code highlight block, so screenreaders
|
||||
// can focus over (particularly important if there's horizontal scroll)
|
||||
// see: https://dequeuniversity.com/rules/axe/4.9/scrollable-region-focusable?application=axeAPI
|
||||
|
||||
jtd.onReady(() => {
|
||||
document
|
||||
.querySelectorAll("div.highlight")
|
||||
.forEach(codeBlock => codeBlock.setAttribute("tabindex", "0"));
|
||||
});
|
||||
|
||||
// Copy button on code
|
||||
|
||||
{%- if site.enable_copy_code_button != false %}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user