Skip to content

Commit fdd87db

Browse files
authored
fix: add keyboard accessibility to Heatmap cells (JhaSourav07#2216)
## Description Closes JhaSourav07#354 Adds proper ARIA grid semantics to the Heatmap component for full keyboard accessibility. **Changes made:** - Added `role="grid"` to outer flex container - Added `role="row"` to each week column - Added `role="gridcell"` to each day cell **Already present (no changes needed):** - `tabIndex={0}` — cells are keyboard focusable - `onFocus` → show tooltip - `onBlur` → hide tooltip - `aria-label` with contribution count and date - `focus:ring-2` for visible focus indicator **Why role="grid" pattern?** `role="gridcell"` alone is insufficient — ARIA spec requires gridcell to be inside a row, and row inside a grid. This makes the heatmap fully accessible to screen readers. ## Pillar ♿ Accessibility ## Checklist - [x] My code follows the project's coding standards - [x] I have run `npm run format` and `npm run lint` - [x] CI Pipeline passing ✅ - [x] No regressions in existing functionality - [x] Closes JhaSourav07#354
2 parents 5f6e285 + d9d46ab commit fdd87db

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

components/dashboard/Heatmap.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,16 @@ export default function Heatmap({
128128
height: (7 * (CELL + GAP) - GAP) * scale,
129129
}}
130130
>
131-
<div className="flex" style={{ gap: GAP }}>
131+
<div className="flex" role="grid" style={{ gap: GAP }}>
132132
{weeks.map((week, wIndex) => (
133-
<div key={wIndex} className="flex flex-col" style={{ gap: GAP }}>
133+
<div key={wIndex} className="flex flex-col" role="row" style={{ gap: GAP }}>
134134
{week.map((day, dIndex) => {
135135
const originalIndex = wIndex * 7 + dIndex;
136136

137137
return (
138138
<div
139139
key={day.date}
140+
role="gridcell"
140141
aria-label={`${getContributionLabel(
141142
day.count
142143
)} on ${formatTooltipDate(day.date)}`}

0 commit comments

Comments
 (0)