Make tier collapse headers keyboard accessible#13
Conversation
Add role="button", tabindex="0", and aria-expanded to tier headers. Handle Enter and Space keydown events to toggle collapse. Extract shared collapse logic into toggleTierCollapse() helper that updates aria-expanded state for screen readers.
Greptile SummaryThis PR improves keyboard accessibility for tier collapse/expand headers in Key issue found:
Minor note:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant KB as Keyboard User
participant HDR as tier-header div (role=button)
participant CB as select-all-checkbox
participant JS as review.js
Note over HDR: tabindex="0", aria-expanded="true"
KB->>HDR: Tab → focus header div
KB->>HDR: Press Enter or Space
HDR->>JS: keydown → onTierHeaderKeydown
JS->>JS: toggleTierCollapse(header)
JS->>HDR: setAttribute("aria-expanded", "false")
JS-->>HDR: tier body hidden
KB->>CB: Tab → focus checkbox (inside header)
KB->>CB: Press Space
CB-->>HDR: keydown bubbles up
HDR->>JS: onTierHeaderKeydown fires
Note over JS: ⚠️ No checkbox guard!<br/>e.preventDefault() blocks<br/>checkbox toggle
JS->>JS: toggleTierCollapse(header)
Note over CB: Checkbox state unchanged (bug)
Reviews (1): Last reviewed commit: "Make tier collapse headers keyboard acce..." | Re-trigger Greptile |
| function onTierHeaderKeydown(e) { | ||
| // Enter or Space toggles collapse (standard button behavior) | ||
| if (e.key === "Enter" || e.key === " ") { | ||
| e.preventDefault(); | ||
| toggleTierCollapse(e.currentTarget); | ||
| } | ||
| } |
There was a problem hiding this comment.
Missing checkbox guard in
onTierHeaderKeydown
onTierHeaderClick correctly bails out when the click target is the select-all-checkbox, but onTierHeaderKeydown has no equivalent guard. Because keydown bubbles, pressing Space while the checkbox has focus will:
- Call
e.preventDefault()— suppressing the checkbox's native toggle behaviour, so the checkbox state never changes. - Proceed to call
toggleTierCollapse, collapsing or expanding the tier instead.
This makes the select-all checkbox completely un-toggleable with the keyboard, which is a regression for keyboard users.
| function onTierHeaderKeydown(e) { | |
| // Enter or Space toggles collapse (standard button behavior) | |
| if (e.key === "Enter" || e.key === " ") { | |
| e.preventDefault(); | |
| toggleTierCollapse(e.currentTarget); | |
| } | |
| } | |
| function onTierHeaderKeydown(e) { | |
| // Don't interfere with the checkbox's native Space behaviour | |
| if (e.target.classList.contains("select-all-checkbox")) return; | |
| // Enter or Space toggles collapse (standard button behavior) | |
| if (e.key === "Enter" || e.key === " ") { | |
| e.preventDefault(); | |
| toggleTierCollapse(e.currentTarget); | |
| } | |
| } |
Summary
role="button",tabindex="0", andaria-expandedto tier header divs in results.htmlkeydownevent handler in review.js — Enter and Space toggle collapse/expandtoggleTierCollapse()that updatesaria-expandedfor screen readers:focus-visibleCSS rulesTest plan
make checkpasses (275 tests, 95.50% coverage)