Skip to content

fix(login): add visible focus indicator for keyboard navigation#2148

Open
mvanhorn wants to merge 1 commit intohackforla:developmentfrom
mvanhorn:osc/2144-login-focus-indicator
Open

fix(login): add visible focus indicator for keyboard navigation#2148
mvanhorn wants to merge 1 commit intohackforla:developmentfrom
mvanhorn:osc/2144-login-focus-indicator

Conversation

@mvanhorn
Copy link
Copy Markdown

Resolves #2144.

Problem

The login form had no explicit :focus / :focus-visible styles, so keyboard users could not tell which input or button was focused. This is a WCAG 2.1 SC 2.4.7 (Focus Visible) violation, as called out in the issue.

Fix

Add focus rings to client/src/sass/AdminLogin.scss covering:

  • The MUI TextField root via :focus-within so the wrapper rings up when the underlying input receives focus.
  • The MUI input itself via :focus-visible for defense in depth on browsers that do not propagate :focus-within reliably.
  • The login button via :focus-visible.

The 2px solid #1976d2 ring matches the MUI primary palette the form's TextField label already uses, with a 2px offset so the ring sits outside the existing border.

Mouse-driven focus stays unstyled because the rules are gated on :focus-visible / :focus-within rather than :focus.

Verification

  • Keyboard Tab navigation now produces a visible 2px ring on each focusable element in the login form.
  • Mouse click does not produce the ring (so the existing visual remains for mouse users).
  • No existing tests cover focus state on the login form, so no test changes were needed.

Resources

Resolves hackforla#2144.

The login form had no explicit :focus / :focus-visible styles, so
keyboard users could not tell which input or button was focused.
This is a WCAG 2.1 SC 2.4.7 (Focus Visible) violation.

Add focus rings to AdminLogin.scss covering:

- The MUI TextField root via :focus-within (so the wrapper rings up
  when the underlying input receives focus).
- The MUI input itself via :focus-visible (defense in depth for
  browsers that do not propagate :focus-within reliably to the
  visual root).
- The login button via :focus-visible.

The 2px solid #1976d2 ring matches the MUI primary palette already
used by the form's TextField label, with a 2px offset so the ring
sits outside the existing border. Mouse-driven focus stays unstyled
because the rules are gated on :focus-visible / :focus-within.

Resources cited in the issue:
- https://www.w3.org/WAI/WCAG21/Understanding/focus-visible.html
- https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible
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.

Login form inputs lack visible focus indicator for keyboard navigation

1 participant