Fix axe scrollable-region-focusable violation on code blocks - #46
Merged
Merged
Conversation
Quarto's theme CSS sets div.sourceCode { overflow: auto; }, making any
code block wider than its container horizontally scrollable, but that
div has no tabindex — a keyboard-only user can't focus it to scroll
(WCAG 2.1.1, axe rule scrollable-region-focusable). Post-render script
now adds tabindex="0" to every sourceCode block.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The matcher must support sourceCode elements with additional classes.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR adds keyboard focusability to horizontally scrollable Quarto code blocks.
Changes:
- Injects
tabindex="0"into rendereddiv.sourceCodeelements. - Preserves idempotent post-render processing.
- Updates the post-render status message.
File summaries
| File | Summary |
|---|---|
scripts/post.py |
Adds focusability handling for rendered code blocks; the matcher misses blocks with additional classes. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # remediation pattern for CSS-scrollable containers and is harmless on | ||
| # blocks that never overflow (just one extra, no-op tab stop). | ||
| TABINDEX_PATTERNS = [ | ||
| re.compile(r'<div class="sourceCode"(?!\s+tabindex)'), |
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.
Summary
div.sourceCode { overflow: auto; }, so any code block wider than its container becomes horizontally scrollable, but the div carries notabindex— keyboard-only users can't focus it to scroll (WCAG 2.1.1, axe rulescrollable-region-focusable).scripts/post.pynow addstabindex="0"to everydiv.sourceCodeblock post-render.sdsrepo'stools/axe_nav_fixes.py, keeping the two toolsets in sync.Test plan
lectures/3.1-Dictionaries.qmd) and confirmed<div class="sourceCode" tabindex="0" ...>in the output.(?!\s+tabindex)) prevents double-injection on re-render.🤖 Generated with Claude Code