WCAG 3.2.2: On Input
Understanding WCAG 3.2.2: On Input (Level A)
WCAG 3.2.2, known as "On Input," is a critical success criterion under the principle of Operable. It mandates that when a user interacts with a form control or any user interface component, changing its setting or value should not automatically trigger a "change of context." The user must explicitly initiate such a change, or be clearly warned about the automatic behavior beforehand.
The core purpose of this criterion is to ensure predictability and control for all users, preventing unexpected shifts in content, focus, or navigation that can disorient and frustrate, especially those with cognitive, motor, or vision impairments.
What is a "Change of Context"?
According to the WCAG glossary, a "change of context" is a significant change in the Web page that, if made without user awareness, can disorient the user. Examples include:
- Opening a new window.
- Moving focus to a different component.
- Going to a new page.
- Significantly re-arranging the content of the page.
Simply updating a small part of the page (e.g., showing an error message, updating a live counter) without moving focus or significantly altering the layout is generally NOT considered a change of context under this criterion, provided it doesn’t disorient the user.
Why WCAG 3.2.2 Matters for Accessibility
Adhering to WCAG 3.2.2 is fundamental for creating an inclusive and predictable user experience. Unexpected changes can severely impact various user groups:
- Users with Cognitive Disabilities: Individuals with cognitive or learning disabilities may struggle to understand why a page suddenly changed or how to return to their previous state. Unexpected shifts can disrupt their concentration and make it difficult to complete tasks.
- Users with Motor Disabilities: Those who use assistive technologies like switch controls, head wands, or mouth sticks may accidentally trigger an input change while trying to navigate or select an option. An automatic context change can cause them to lose their place or activate an unintended action, requiring significant effort to recover.
- Screen Reader Users: Screen readers announce changes in the document. An automatic context change can interrupt their reading flow, making them lose their place and forcing them to re-orient themselves to the new content or page, which can be disorienting and time-consuming.
- Users with Low Vision / Screen Magnifiers: When using screen magnifiers, only a portion of the screen is visible. An automatic context change can move the magnified area to an unexpected location, causing the user to lose their current view and forcing them to scroll extensively to find their place again.
- Speech Input Users: Users who control their devices with voice commands might accidentally utter a command that changes an input’s value, leading to an unwanted context change before they are ready.
In essence, this criterion champions user control, ensuring that the user, not the system, dictates when significant changes occur on a web page.
Success Criterion 3.2.2: On Input (Level A)
The official wording for this success criterion is:
Changing the setting of any user interface component does not automatically cause a change of context unless the user has been advised of the behavior before using the component.
Key Terms Explained:
- Changing the setting: This refers to modifying the value or state of a UI component, such as selecting an item in a dropdown, typing text into an input field, checking a checkbox, or selecting a radio button.
- User interface component: Any part of the content that users interact with, including form controls, links, buttons, and other interactive elements.
- Automatically cause: The change of context happens as a direct, immediate consequence of modifying the component’s setting, without an explicit user action like clicking a "Submit" button.
- Change of context: As defined above, significant alterations like new pages, new windows, focus shifts, or major content re-arrangements.
- Advised of the behavior: The user is clearly informed about the automatic context change *before* they interact with the component. This warning should be prominent and easily perceivable (e.g., text adjacent to the control, in an accessible tooltip, or within instructions). This exception is difficult to implement effectively and is generally discouraged as a primary compliance strategy for Level A.
Practical Guidelines for Compliance
To ensure your web content meets WCAG 3.2.2, follow these practical guidelines:
- Require Explicit Submission: For forms, always include a dedicated submit button or link that the user must activate to finalize their input and trigger any context changes (like navigating to a results page).
- Avoid Automatic Page Reloads/Navigation: Do not use JavaScript to automatically submit a form, reload a page, or navigate to a new URL solely based on a change to an input field (e.g.,
onchange
event on a dropdown,onkeyup
on a text field). - Local Updates are Generally Okay: It is acceptable for an input change to dynamically update other parts of the *same page* without causing a change of context. For example, filtering a list of items on the page, displaying validation errors, or showing/hiding related form fields. However, ensure such updates do not unexpectedly move the user’s focus or disrupt their current task.
- Provide Clear Warnings (If Absolutely Necessary): If an automatic context change is unavoidable for a specific component (which should be rare and carefully justified), you *must* inform the user of this behavior before they interact with it. The warning should be clear, concise, and accessible.
- Client-Side Validation: Displaying validation errors or feedback on the same page immediately after an input is generally acceptable, as long as it doesn’t cause a "change of context."
Examples of Correct and Incorrect Implementations
Incorrect Implementations
These examples show common violations of WCAG 3.2.2.
<!-- INCORRECT: Dropdown automatically submits form and reloads page -->
<form action="/filter-results" method="get">
<label for="category-select">Select Category:</label>
<select id="category-select" name="category" onchange="this.form.submit()">
<option value="all">All</option>
<option value="electronics">Electronics</option>
<option value="books">Books</option>
</select>
</form>
<!-- INCORRECT: Text input triggers search and navigates on every keypress -->
<label for="search-input">Search:</label>
<input type="text" id="search-input" onkeyup="window.location.href='/search?q=' + this.value;">
In both incorrect examples, merely changing the value of the input field (selecting an option or typing a character) causes an automatic context change (page reload or navigation) without explicit user confirmation, violating 3.2.2.
Correct Implementations
These examples demonstrate how to comply with WCAG 3.2.2.
<!-- CORRECT: Dropdown requires explicit submit button -->
<form action="/filter-results" method="get">
<label for="category-select-correct">Select Category:</label>
<select id="category-select-correct" name="category">
<option value="all">All</option>
<option value="electronics">Electronics</option>
<option value="books">Books</option>
</select>
<button type="submit">Apply Filter</button>
</form>
<!-- CORRECT: Text input updates a list on the same page (no context change) -->
<label for="filter-input">Filter Items:</label>
<input type="text" id="filter-input" oninput="filterList(this.value)" aria-describedby="filter-info">
<p id="filter-info" class="sr-only">Type to filter the list below.</p>
<ul id="item-list">
<li>Apple</li>
<li>Banana</li>
<li>Orange</li>
<li>Grape</li>
</ul>
<script>
function filterList(searchTerm) {
const items = document.querySelectorAll('#item-list li');
items.forEach(item => {
if (item.textContent.toLowerCase().includes(searchTerm.toLowerCase())) {
item.style.display = '';
} else {
item.style.display = 'none';
}
});
}
</script>
<!-- CORRECT: Checkbox toggles visibility of a section on the same page -->
<input type="checkbox" id="show-details" aria-controls="additional-details" onchange="toggleDetails()">
<label for="show-details">Show additional details</label>
<div id="additional-details" style="display: none;">
<p>These are the extra details that appear when the checkbox is checked.</p>
</div>
<script>
function toggleDetails() {
const details = document.getElementById('additional-details');
details.style.display = details.style.display === 'none' ? 'block' : 'none';
}
</script>
In the correct examples, the dropdown uses a submit button. The text input only filters content on the same page without navigating or submitting. The checkbox merely toggles a section’s visibility on the current page, which is not considered a change of context. These updates do not disorient the user or unexpectedly shift their focus.
Best Practices and Common Pitfalls
Best Practices
- Prioritize User Control: Always give users explicit control over when context changes occur.
- Use Semantic HTML: Leverage standard HTML form elements and ensure they are properly labeled and grouped.
- Test with Assistive Technologies: Regularly test your forms and interactive elements with screen readers, keyboard navigation, and other assistive tools to identify any unexpected behaviors.
- Provide Clear Feedback: When dynamic updates happen on the same page (e.g., filtering, validation), ensure the changes are perceivable and understandable, without being disorienting.
- Accessible Warnings: If an automatic context change is unavoidable and permissible (due to prior warning), ensure the warning itself is highly accessible and perceivable to all users before they interact with the component.
Common Pitfalls
- "Autocomplete" without a Button: Implementing search fields or filters that automatically submit or navigate as the user types without an explicit "Search" or "Apply" button.
- Dropdowns as Navigational Tools: Using a
<select>
element to immediately jump to another page or section on change. - Ignoring the "Advised" Clause: Relying on the "unless advised" exception without implementing a clear, prominent, and accessible warning for all users. It’s often safer and more user-friendly to simply avoid automatic context changes.
- Unexpected Focus Shifts: Even if a change doesn’t trigger a full page reload, if it unexpectedly moves the user’s focus far away from their current interaction point, it can still be disorienting.
Conclusion
WCAG 3.2.2 "On Input" is vital for creating predictable and user-friendly web interfaces. By ensuring that user interface components do not automatically trigger context changes upon input, we empower users with control, reduce cognitive load, and prevent disorientation. Adhering to this criterion significantly improves the accessibility and usability of web forms and interactive elements for everyone, fostering a more inclusive digital environment.