- Success Criterion 3.2.2
- Conformance level A
Control Inside a Dialog That Accidentally Closes the Whole Dialog
3.2.2 — On Input
Scenario
Setting
A grocery delivery app's shopping cart
What’s wrong
Interacting with a control inside an overlay unexpectedly closes the overlay — the user presses an in-dialog button and the whole dialog vanishes mid-task.
Example
<div role="dialog" onclick="closeDialog()">
<button onclick="removeItem(itemId)">Remove item</button>
</div> Why it matters
Because the click handler sits on the whole dialog, tapping Remove item also fires the dialog's own close handler, so the cart dialog vanishes right after the user removes one item.
How to test
Press a button inside an open overlay/dialog: if it unexpectedly closes the entire overlay instead of just performing its own action, it fails.
How to fix
Attach the close behavior to its own explicit control, and stop click events from bubbling out of interactive children.
<div role="dialog">
<button onclick="removeItem(itemId); event.stopPropagation();">Remove item</button>
<button onclick="closeDialog()">Close</button>
</div> Outcome
A shopper removes an item and keeps editing the rest of the cart in the same dialog.
Who is affected
Users with limited dexterity who rely on large tap targets, and screen reader users, both lose the dialog mid-task and must reopen the cart to keep editing it.
Learn more
- Understanding Understanding document (opens in a new tab)
Related scenarios
- Form That Submits Itself the Moment the Last Field Is Filled
- Selecting an Option That Opens a New Window With No Warning
- Dropdown That Navigates to a New Page on Selection
- Checking a Box That Reloads the Page and Loses Entries
- Country Selector That Re-Renders the Form and Drops Focus
- Search Box That Auto-Navigates Once Enough Characters Are Typed