Improve semantic naming and practices for scrollable code blocks#348
Improve semantic naming and practices for scrollable code blocks#348ruslanpashkov wants to merge 1 commit intoexpressive-code:mainfrom
Conversation
✅ Deploy Preview for expressive-code ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Initially, it was decided to implement |
|
@delucis Would it be possible for you to review this PR as it was created based on a discussion you had? |
|
Hello @ruslanpashkov, thank you for this PR! Sorry for the long delay in reviewing it. I've now had a look at it, read through your linked discussion with @delucis, and the changes in this PR look good to me overall. There are two aspects I'd like to discuss:
|
Background
Previous changes addressed Arc Toolkit compliance but introduced
axe-coreviolations with "best practices" rules. After discussion with @delucis (original conversation), we identified thatrole="region"was inappropriate for scrollable code blocks and needed a more semantic approach.Changes Made
1. Semantic Module Renaming
tabindex-js-module.ts→a11y-js-module.ts2. Improved Role Semantics
role="region"→role="group"role="region"creates landmark regions that need labels and add navigation noiserole="group"provides semantic grouping without landmark overhead3. Enhanced Screen Reader Support
<span class="sr-only">labels with unique IDsaria-label:aria-labeldoesn't translate properly)4. Improved Variable Naming
hasTabIndex→isFocusableneedsTabIndex→isScrollableupdateTabIndex→updateAccessibilityTesting Completed
Screen Readers: VoiceOver, NVDA
Auto-translation: Browser translation works with
sr-onlylabelsAutomated Tools: axe-core, Arc Toolkit, WAVE (all passing)
WCAG Compliance: 4.1.2 Name, Role, Value satisfied
Visual Testing Results
Example of generated HTML structure
VoiceOver now can read the scrollable code blocks easly
Scrollable code blocks now under the Form Controls in VoiceOver Rotor
No more noise of code blocks in landmark elements