Skip to content

Restore visible focus indicator for keyboard tab navigation#6938

Merged
compwron merged 1 commit intorubyforgood:mainfrom
mvanhorn:fix-tab-focus-outline
May 5, 2026
Merged

Restore visible focus indicator for keyboard tab navigation#6938
compwron merged 1 commit intorubyforgood:mainfrom
mvanhorn:fix-tab-focus-outline

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented May 5, 2026

Closes #6065

Why

The blanket :focus rule near the top of public/assets/css/main.css strips both outline and box-shadow from anchors, inputs, textareas, buttons, and the Bootstrap .btn family. With both indicators gone, keyboard users get zero visual feedback while tabbing through forms - the case-contact form was the example in the issue but it affects the whole app. That is a WCAG 2.4.7 (Focus Visible) failure on a tool whose users include CASA volunteers and supervisors who do rely on keyboard navigation.

What

Scope the existing reset to :focus:not(:focus-visible) so mouse click-focus still looks clean, and add a sibling :focus-visible rule that draws a 2px outline in the project blue (#4a6cf7) with 2px offset.

a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
button:focus:not(:focus-visible),
.btn:focus:not(:focus-visible),
...

a:focus-visible,
input:focus-visible,
textarea:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid #4a6cf7;
  outline-offset: 2px;
}

.btn.focus and .btn:active/.btn.active are left on the reset rule because those are Bootstrap state classes, not the :focus pseudo-class - they shouldn't gain an outline just for being the active item.

Notes

  • :focus-visible browser support is now universal (Chrome 86+, Firefox 85+, Safari 15.4+). Older browsers fall back silently to the still-present :focus rule.
  • The other outline: none declarations later in the file (.select-style-{1,2,3} .select-position select:focus at lines 1226 / 1286 / 1340) are scoped to styled selects that change border-color on focus, so they still communicate focus and are out of scope here.

Verification

bin/dev, log in as volunteer1@example.com, navigate to a case, click "Create New Contact" and tab through the form - every input and the submit button now shows the blue outline. Mouse clicks do not.

Closes rubyforgood#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.
Copy link
Copy Markdown
Collaborator

@compwron compwron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feedback: provide screenshots on UI impacting PRs please :)

@compwron compwron merged commit 10b9deb into rubyforgood:main May 5, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Tab Navigation of forms lacks focus outline for certain inputs

2 participants