- Success Criterion 2.4.7
- Conformance level AA
- W3C reference F55
Element Losing Keyboard Focus the Instant It’s Reached
2.4.7 — Focus Visible
Scenario
Setting
A video streaming service's show detail page
What’s wrong
As soon as an element receives keyboard focus, a script throws focus away (blur) — keyboard users can never actually reach or use it.
Example
playButton.addEventListener('focus', () => {
playButton.blur();
startPreviewAnimation();
}); Why it matters
The moment Tab reaches the Play button, the script blurs it immediately, so the keyboard user can never actually press it.
How to test
Tab to an element and check if it loses focus immediately (blur() firing on focus): if so, no indicator has a chance to display and it fails.
How to fix
Calling .blur() inside a focus handler makes an element permanently unreachable by keyboard.
playButton.addEventListener('mouseenter', startPreviewAnimation); Outcome
A viewer tabs to Play and presses Enter, and the show starts immediately.
Who is affected
Keyboard-only users can't operate any control that a script blurs on focus, no matter how many times they press Tab.
Learn more
- Understanding Understanding document (opens in a new tab)
- Technique Related technique (opens in a new tab)
Related scenarios
- Focus Outline Removed by CSS With No Replacement
- Global CSS Reset Removing Every Focus Outline Site-Wide
- Focus Indicator Styled for Some Components but Not Others
- Focus Indicator That’s Just a Subtle, Hard-to-See Color Shift
- Focus Style That Only Appears on Hover, Never on Tab Focus
- Focus Indicator Hidden Behind an Overlapping Sticky Element