Skip to content

Commit 10b9deb

Browse files
authored
Restore visible focus indicator for keyboard tab navigation (#6938)
Closes #6065. The blanket `:focus` rule in `public/assets/css/main.css` strips `outline` and `box-shadow` from anchors, inputs, textareas, buttons, and the Bootstrap `.btn` family. With both indicators gone, keyboard users lose all visual feedback while tabbing through forms (the case-contact form was called out specifically) -- a serious WCAG 2.4.7 "Focus Visible" failure for an app whose users include CASA volunteers and supervisors who rely on keyboard navigation. Scope the existing reset to `:focus:not(:focus-visible)` so mouse click-focus stays clean, and add a sibling `:focus-visible` rule that draws a 2px outline in the project blue (#4a6cf7) with 2px offset. Browser support for `:focus-visible` is universal at this point (Chrome 86+, Firefox 85+, Safari 15.4+); pre-`:focus-visible` browsers silently fall back to the still-present `:focus` rule. The `.btn.focus` and `.btn:active`/`.btn.active` selectors are left on the reset rule because they represent intentional Bootstrap state classes, not the `:focus` pseudo-class -- they should not gain a focus ring just for being active. Other `outline: none` rules (`.select-style-{1,2,3} .select-position select:focus` at lines 1226/1286/1340) are scoped to selects that get a `border-color` change as their focus indicator, so they still communicate focus and are out of scope here. Tested locally: tabbing through `/cases/.../case_contacts/new` now shows the blue outline on every input and the submit button; mouse clicks do not.
1 parent 55c9312 commit 10b9deb

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

public/assets/css/main.css

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ body {
2020
-moz-box-sizing: border-box;
2121
box-sizing: border-box; }
2222

23-
a:focus,
24-
input:focus,
25-
textarea:focus,
26-
button:focus,
27-
.btn:focus,
23+
a:focus:not(:focus-visible),
24+
input:focus:not(:focus-visible),
25+
textarea:focus:not(:focus-visible),
26+
button:focus:not(:focus-visible),
27+
.btn:focus:not(:focus-visible),
2828
.btn.focus,
2929
.btn:not(:disabled):not(.disabled).active,
3030
.btn:not(:disabled):not(.disabled):active {
@@ -34,6 +34,14 @@ button:focus,
3434
-moz-box-shadow: none;
3535
box-shadow: none; }
3636

37+
a:focus-visible,
38+
input:focus-visible,
39+
textarea:focus-visible,
40+
button:focus-visible,
41+
.btn:focus-visible {
42+
outline: 2px solid #4a6cf7;
43+
outline-offset: 2px; }
44+
3745
a:hover {
3846
color: #4a6cf7; }
3947

0 commit comments

Comments
 (0)