WCAG Success Criteria · Level A
WCAG 3.2.1: On Focus
WCAG 3.2.1 On Focus requires that when any user interface component receives keyboard focus, it must not trigger an unexpected change of context. This protects keyboard and assistive technology users from disorienting, unpredictable behavior that can make a page impossible to navigate effectively.
- Level A
- Wcag
- Wcag 2 2 a
- Understandable
- Accessibility
What This Rule Means
WCAG Success Criterion 3.2.1 On Focus (Level A) states: "If any component receives focus, it does not initiate a change of context." In plain terms, the act of moving focus to an interactive element — by pressing Tab, Shift+Tab, arrow keys, or any other keyboard mechanism — must not by itself cause something dramatic and unexpected to happen on the page.
A change of context is defined by WCAG as a major change in the content of the page that, if made without user awareness, could disorient the user. The specification identifies four concrete types of context change: changes to the user agent (such as spawning a new browser window or tab), changes to the viewport (such as automatic scrolling to a distant part of the page), changes to focus itself (such as automatically moving focus somewhere else), and changes to content that significantly alter the meaning of the page (such as submitting a form or loading a completely different view).
The key distinction the criterion draws is between receiving focus and activating a control. Tabbing onto a button and thereby causing it to submit a form is a violation. But pressing Enter or Space while that button is focused — an intentional, deliberate activation — is perfectly acceptable and even expected. The user's intention is what separates a predictable interaction from a disorienting one.
Common patterns that fail this criterion include:
- A
<select>dropdown that automatically navigates to a new URL as soon as an option receives focus (not when the user confirms their choice). - A date-picker widget that opens a modal dialog the moment any of its input fields receives focus, without any user activation.
- A carousel or slideshow that auto-advances to the next slide when its navigation dots receive focus.
- A tooltip or popover that, when triggered by focus, simultaneously moves keyboard focus to itself without warning, stranding the user in an unexpected location.
- A search field that immediately submits and reloads the page when it receives focus.
Patterns that are explicitly not violations include: a tooltip or description panel that appears visually but does not move focus or alter the page's primary content; a focus indicator highlight (such as an outline or ring) appearing around the focused element; or an element expanding to show additional content inline, as long as focus remains where the user placed it.
There are no official exceptions defined in WCAG 3.2.1. The criterion applies universally to all UI components on a page. However, the WCAG Understanding document notes that context changes triggered by a user's deliberate activation (click, Enter, Space) fall outside the scope of this criterion, which concerns only the passive act of receiving focus.
Why It Matters
The On Focus criterion sits within Principle 3 — Understandable — because predictability is a fundamental prerequisite for usability. When a page behaves unexpectedly in response to focus alone, the consequences range from mild confusion to complete loss of access, depending on the user's needs and tools.
Keyboard-only users (people who cannot use a mouse due to motor impairments, repetitive strain injuries, or paralysis) rely exclusively on keyboard navigation. When tabbing into a form field triggers a page reload, they may lose all the data they have already entered and find themselves redirected away from their goal. Recovering from such a disruption can take significant time and effort — or they may simply give up entirely.
Screen reader users (who are often also keyboard-only users) face an additional layer of disorientation. Screen readers announce the currently focused element to the user. If focus unexpectedly jumps to a new element — say, a modal that opened automatically — the screen reader announces the new context without giving the user any frame of reference for what just happened or why. This is analogous to being physically picked up and moved to a different room without warning.
Users with cognitive disabilities, including those with ADHD, anxiety disorders, or memory impairments, depend on predictable interfaces to build and maintain a mental model of a page. Sudden, unexplained changes in context shatter that model, creating confusion, anxiety, and errors. A study by the WebAIM Million project consistently finds that complex interactive components with unexpected behaviors are among the top sources of accessibility complaints from users with cognitive disabilities.
Users with low vision who use screen magnification software (such as ZoomText or Windows Magnifier) see only a small portion of the screen at a time. If focus causes an automatic scroll or navigation, the relevant content may move completely out of their zoomed viewport, leaving them staring at a blank or unrelated area of the screen.
Consider a concrete real-world scenario: a Turkish bank's online money transfer form contains a dropdown menu for selecting the destination bank. The developer has implemented an onchange-style event on the <select> element that fires not on confirmation but as soon as any option receives arrow-key focus. A screen reader user tabbing into the field and pressing the Down arrow to explore available banks immediately triggers a form submission or page reload. They never complete the transfer and cannot determine what went wrong. This scenario is not hypothetical — it was a documented pattern in many early single-page applications.
Beyond accessibility, there are tangible usability and business benefits. Forms that do not hijack focus have lower abandonment rates. Pages that behave predictably score better on usability testing with all audiences. Search engine crawlers also benefit from predictable navigation flows, since unexpected redirects triggered by focus events can confuse crawling logic in certain dynamic rendering scenarios.
Related Axe-core Rules
WCAG 3.2.1 On Focus requires manual testing because automated tools cannot reliably determine user intent or predict all possible context changes. Axe-core and similar automated scanners can parse static HTML and ARIA attributes, but they cannot observe runtime JavaScript behavior in response to focus events — particularly whether that behavior constitutes a "major" context change as defined by WCAG. A script that moves focus, submits a form, or navigates to a URL on the focus event is invisible to a static scanner unless the tool actually simulates focus interactions across every interactive element and then analyzes what changed in the DOM, viewport, and URL afterward. This level of behavioral simulation is not reliably achievable in an automated pass without a prohibitively high false-positive rate.
- Manual Testing Required — On Focus Context Change: Testers must manually tab through every interactive element on the page (links, buttons, inputs, selects, custom widgets) and observe whether focus alone — without any activation — triggers a change of context as defined by WCAG. This includes watching for URL changes, new windows or tabs opening, focus moving away from the current element, form submissions, and major content replacements. Automated tools flag JavaScript event listeners attached to focus-related events (
focus,focusin,onfocus) as candidates for manual review, but cannot determine whether those handlers cause a disqualifying context change.
How to Test
- Automated pre-scan: Run axe DevTools (browser extension or CLI) or Google Lighthouse against the page. While neither tool can definitively flag On Focus violations, axe DevTools may surface related issues with focus management (such as
scrollable-region-focusableor focus-trap patterns) that warrant closer manual inspection. Use the axe DevTools "Needs Review" panel — items flagged there often relate to interactive component behaviors that require human judgment. - Identify all interactive elements: Before keyboard testing, make a list of all interactive components: links, buttons, form inputs, dropdowns, checkboxes, radio buttons, date pickers, carousels, accordions, tabs, modals, and any custom widgets using
tabindex. Pay special attention to custom JavaScript widgets that listen forfocusorfocusinevents. - Keyboard-only navigation test: Using only the keyboard (no mouse), press Tab sequentially through every focusable element on the page. After each Tab keypress, before pressing anything else, observe: Did the URL change? Did a new window or tab open? Did focus move away from the element you just tabbed to? Did a form submit? Did the primary page content change dramatically? Any "yes" answer is a candidate violation.
- Select element test: Focus any
<select>dropdown. Use the Up and Down arrow keys to move through options without pressing Enter or Space. Verify that navigating through options does not trigger any navigation, form submission, or context change. This is one of the most commonly violated patterns. - NVDA + Firefox: Enable NVDA (free, Windows). Open Firefox and navigate to the page. Press Tab through all interactive elements. Listen to NVDA's announcements — if NVDA begins announcing a completely different part of the page or a new page context after a Tab press (without you pressing Enter or Space), this is a strong signal of a violation.
- JAWS + Chrome: Enable JAWS. Open Chrome. Use Tab to navigate. JAWS will announce each focused element. Monitor for unexpected announcements of new dialogs, pages, or focus locations that you did not deliberately navigate to.
- VoiceOver + Safari (macOS/iOS): Enable VoiceOver (Cmd+F5 on macOS). Navigate with Tab (or swipe on iOS). Monitor for unexpected context shifts. On iOS, also test with switch access to simulate users with severe motor impairments who navigate by scanning.
- Browser DevTools event listener inspection: In Chrome DevTools, select any suspicious interactive element, go to the Elements panel, and click "Event Listeners." Look for
focusorfocusinlisteners. If present, review the attached JavaScript to determine whether the handler triggers navigation, form submission, focus movement, or other context-changing actions.
How to Fix
Auto-submitting select dropdown — Incorrect
<!-- FAIL: Selecting an option via arrow key immediately navigates to a new URL -->
<label for='region'>Select Region</label>
<select id='region' onchange='window.location = this.value;'>
<option value='/istanbul'>Istanbul</option>
<option value='/ankara'>Ankara</option>
<option value='/izmir'>Izmir</option>
</select>
Auto-submitting select dropdown — Correct
<!-- PASS: Navigation only occurs when the user explicitly activates the Go button -->
<label for='region'>Select Region</label>
<select id='region'>
<option value='/istanbul'>Istanbul</option>
<option value='/ankara'>Ankara</option>
<option value='/izmir'>Izmir</option>
</select>
<button type='button' onclick='navigateToRegion()'>Go</button>
<script>
function navigateToRegion() {
var select = document.getElementById('region');
window.location = select.value; // Only fires on deliberate button activation
}
</script>
Modal opening on input focus — Incorrect
<!-- FAIL: Focusing the date input immediately opens a modal dialog and moves focus -->
<label for='departure'>Departure Date</label>
<input type='text' id='departure' onfocus='openDatePickerModal()' />
<script>
function openDatePickerModal() {
var modal = document.getElementById('date-modal');
modal.style.display = 'block';
modal.querySelector('button').focus(); // Moves focus away without user intent
}
</script>
Modal opening on input focus — Correct
<!-- PASS: The date picker opens only when the user explicitly clicks or presses Enter/Space -->
<label for='departure'>Departure Date</label>
<input type='text' id='departure' readonly aria-haspopup='dialog'
aria-label='Departure Date — press Enter to open date picker' />
<button type='button' id='open-picker'
aria-controls='date-modal'
onclick='openDatePickerModal()'>
Choose Date
</button>
<script>
function openDatePickerModal() {
// Only called on explicit activation (click or Enter/Space on the button)
var modal = document.getElementById('date-modal');
modal.removeAttribute('hidden');
modal.querySelector('[data-initial-focus]').focus();
}
</script>
Carousel auto-advancing on focus — Incorrect
<!-- FAIL: Focusing a navigation dot advances the carousel slide, changing page content -->
<div class='carousel-dots'>
<button class='dot' onfocus='showSlide(0)'>1</button>
<button class='dot' onfocus='showSlide(1)'>2</button>
<button class='dot' onfocus='showSlide(2)'>3</button>
</div>
Carousel auto-advancing on focus — Correct
<!-- PASS: The carousel only changes slides when the dot is explicitly activated (click/Enter) -->
<div class='carousel-dots' role='tablist' aria-label='Carousel navigation'>
<button class='dot' role='tab' aria-selected='true'
aria-controls='slide-0' onclick='showSlide(0)'>
Slide 1
</button>
<button class='dot' role='tab' aria-selected='false'
aria-controls='slide-1' onclick='showSlide(1)'>
Slide 2
</button>
<button class='dot' role='tab' aria-selected='false'
aria-controls='slide-2' onclick='showSlide(2)'>
Slide 3
</button>
</div>
<!-- onclick only fires on deliberate activation, not on Tab focus -->
Common Mistakes
- Using
onfocusas a substitute foronclickon navigation elements: Developers sometimes attachonfocushandlers to navigation links or buttons to "pre-load" a destination, accidentally triggering a full navigation instead of just a prefetch. Always useonclickoronkeydown(checking for Enter/Space) for any action that changes context. - Binding
onchangeon<select>elements without a submit action: In desktop browsers,onchangeon a<select>fires when an option is confirmed, but in some older implementations and certain mobile browsers it can fire as arrow keys move through options. Always pair select-driven navigation with an explicit submit button or use a<form>with a<button type='submit'>. - Moving focus programmatically inside a
focusevent handler: Callingelement.focus()inside another element'sonfocusorfocusinhandler creates an unexpected focus jump. This is a direct violation — the user tabbed to element A and focus silently moved to element B. Always move focus only in response to deliberate user actions. - Opening modal dialogs on focus events of any trigger element: A common shortcut is attaching a modal-open handler to the
focusevent of a trigger button or input field. Modals must only open in response to a click, Enter key, or Space key — never on focus alone. - Auto-playing media or animations that change viewport context on focus: A hero banner that begins a full-screen video or a large animation the moment its play button receives focus changes the visual context significantly. Tie play actions to activation events, not focus events.
- Triggering live region updates that scroll the page to new content on focus: Some dynamic widgets update a live region and then scroll the viewport to that region as soon as an input receives focus. This changes the viewport context and disorients screen magnification users. Decouple live region updates from focus events where possible.
- Implementing custom focus traps that immediately trap users without disclosure: A custom component that intercepts all Tab keypresses the moment it receives focus, without announcing to the user that they are inside a focus trap, violates both the letter and spirit of this criterion. Focus traps are only appropriate inside fully open modal dialogs, and users must be informed how to exit.
- Using CSS
:focusto triggerdisplay: blockon dropdown menus that contain focusable children, causing cascading unexpected focus movement: CSS-only focus-driven menus that reveal focusable items can cause confusing jumps when the browser's focus order then moves into the newly visible items. Ensure revealed menus are expected and clearly communicated via ARIA attributes likearia-expanded. - Relying on third-party widget libraries without auditing their focus behavior: Many UI component libraries (date pickers, rich text editors, select2-style dropdowns) have historically violated 3.2.1 by opening popups or moving focus on
focusevents. Always audit third-party components manually before deployment, regardless of the library's accessibility claims. - Forgetting to test in single-page application (SPA) routing contexts: In React, Vue, and Angular SPAs, focus events on navigation links can sometimes trigger route changes via the router's prefetch logic or event bubbling, especially when focus events are not properly stopped from propagating. Test SPA navigation components explicitly for 3.2.1 compliance.
Relation to Turkey's Accessibility Regulations
Turkey's Presidential Circular 2025/10, published in Official Gazette No. 32933 on June 21, 2025, establishes mandatory web accessibility requirements that explicitly reference WCAG 2.2 as the technical standard. WCAG 3.2.1 On Focus is a Level A criterion, which means it sits at the baseline of mandatory compliance under the circular. There are no exemptions for Level A criteria — all covered entities must meet them within the defined timelines.
Public institutions are required to achieve full conformance within one year of the circular's publication date. Private sector entities within scope are given two years. The covered entities under Presidential Circular 2025/10 include a broad range of organizations: all public institutions and agencies, e-commerce platforms and online marketplaces, banks and financial institutions, hospitals and private healthcare providers, telecommunications companies with 200,000 or more subscribers, travel agencies and booking platforms, private transport companies, and private schools and educational institutions authorized by the Ministry of National Education (MoNE).
The relevance of WCAG 3.2.1 On Focus to these entity types is direct and practical. Consider an e-commerce platform where a product category dropdown auto-navigates on focus — a keyboard-using customer with a mobility impairment cannot browse product categories and will abandon the purchase. A bank's online transfer form with focus-triggered submissions could cause unintended financial transactions or repeated failed attempts for screen reader users. A hospital appointment booking system where date fields open modals on focus may prevent patients with disabilities from scheduling care independently.
Under the circular, failure to comply exposes covered entities to administrative sanctions and reputational risk. For entities currently undergoing digital transformation or procuring new web systems, building WCAG 3.2.1 compliance into procurement requirements and developer guidelines now — rather than retrofitting after a complaint — is both more cost-effective and more aligned with the spirit of the regulation. Organizations using the Accsible overlay SDK benefit from built-in focus management tools that help identify and remediate unexpected on-focus behaviors as part of a broader WCAG 2.2 Level A compliance workflow.
Fonti e riferimenti
- W3C Understanding 3.2.1 On Focus
- W3C Techniques for 3.2.1 On Focus
- WebAIM: Keyboard Accessibility
- MDN: HTMLElement: focus event
- MDN: tabindex attribute
- W3C G107: Using activate rather than focus as a trigger for changes of context
- W3C F55: Failure due to using script to remove focus when focus is received
