Skip to content

Commit c96ef95

Browse files
committed
♻️ refactor: sourcery review suggestions
1 parent ce20862 commit c96ef95

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

frontend/css/users.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
outline: 3px solid var(--color-emerald-500); /* high-contrast focus ring */
3737
outline-offset: 2px;
3838
}
39+
/* When disabling a button, also set tabindex="-1" in the HTML to prevent keyboard focus */
3940
.users-btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
4041

4142
/* primary button (stands out on white) */

frontend/js/pages/Users.tsx

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,33 @@ const Users = () => {
3636
</span>
3737

3838
<div className="flex items-center gap-2">
39-
<Link
40-
aria-disabled={!prev}
41-
className="users-btn users-btn--primary"
42-
to={prev || "#"}
43-
onClick={(e) => !prev && e.preventDefault()}
44-
>
45-
← Previous
46-
</Link>
47-
<Link
48-
aria-disabled={!next}
49-
className="users-btn users-btn--primary"
50-
to={next || "#"}
51-
onClick={(e) => !next && e.preventDefault()}
52-
>
53-
Next →
54-
</Link>
39+
{/* Anchor elements do not natively support 'aria-disabled', which can cause accessibility issues. To improve accessibility, use 'tabIndex={-1}' with 'aria-disabled', or render a instead of when disabled. */}
40+
{!prev ? (
41+
<span
42+
aria-disabled="true"
43+
className="users-btn users-btn--primary users-btn--disabled"
44+
tabIndex={-1}
45+
>
46+
← Previous
47+
</span>
48+
) : (
49+
<Link className="users-btn users-btn--primary" to={prev}>
50+
← Previous
51+
</Link>
52+
)}
53+
{!next ? (
54+
<span
55+
aria-disabled="true"
56+
className="users-btn users-btn--primary users-btn--disabled"
57+
tabIndex={-1}
58+
>
59+
Next →
60+
</span>
61+
) : (
62+
<Link className="users-btn users-btn--primary" to={next}>
63+
Next →
64+
</Link>
65+
)}
5566
</div>
5667
</div>
5768
</section>

0 commit comments

Comments
 (0)