Commit 198cd4d
authored
fix(a11y): add focus trap and ARIA dialog semantics to Compare Profile modal (JhaSourav07#2146)
## Description
Fixes JhaSourav07#2139
The Compare Profile modal in `DashboardClient.tsx` was implemented as a
plain `<div>` without proper ARIA dialog semantics or keyboard focus
management, violating WCAG 2.1 SC 2.4.3 (Focus Order) and SC 4.1.2
(Name, Role, Value).
**Changes:**
- Added `role="dialog"`, `aria-modal="true"`, and
`aria-labelledby="compare-modal-title"` to the modal container
- Added `id="compare-modal-title"` to the modal heading for the
`aria-labelledby` reference
- Implemented a keyboard focus trap (`handleModalKeyDown`) that
constrains Tab/Shift+Tab within the modal
- Added `ref={compareInputRef}` to auto-focus the input field when the
modal opens
- Added `ref={triggerRef}` to the "Compare Profile" button to restore
focus when the modal closes
- Added `ref={modalRef}` to the modal content for focus trap element
querying
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [ ] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [x] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
N/A — this is a keyboard/screen reader accessibility fix. The visual
appearance is unchanged.
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
- [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
- [x] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have started the repo.
- [x] I have made sure that i have only one commit to merge in this PR.
- [ ] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [x] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.1 file changed
Lines changed: 68 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
330 | 334 | | |
331 | 335 | | |
332 | 336 | | |
| |||
338 | 342 | | |
339 | 343 | | |
340 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
341 | 392 | | |
342 | 393 | | |
343 | 394 | | |
| |||
500 | 551 | | |
501 | 552 | | |
502 | 553 | | |
| 554 | + | |
503 | 555 | | |
504 | 556 | | |
505 | 557 | | |
| |||
996 | 1048 | | |
997 | 1049 | | |
998 | 1050 | | |
999 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
1000 | 1055 | | |
1001 | 1056 | | |
1002 | 1057 | | |
1003 | 1058 | | |
1004 | 1059 | | |
1005 | 1060 | | |
1006 | 1061 | | |
| 1062 | + | |
1007 | 1063 | | |
1008 | 1064 | | |
1009 | 1065 | | |
1010 | 1066 | | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1011 | 1071 | | |
1012 | 1072 | | |
1013 | 1073 | | |
1014 | 1074 | | |
| 1075 | + | |
1015 | 1076 | | |
1016 | 1077 | | |
1017 | 1078 | | |
| |||
1024 | 1085 | | |
1025 | 1086 | | |
1026 | 1087 | | |
1027 | | - | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
1028 | 1092 | | |
1029 | 1093 | | |
1030 | 1094 | | |
| |||
1036 | 1100 | | |
1037 | 1101 | | |
1038 | 1102 | | |
| 1103 | + | |
1039 | 1104 | | |
1040 | 1105 | | |
1041 | 1106 | | |
| |||
0 commit comments