- Level
- A
- Since
- WCAG 2.1
2.5.2 Pointer Cancellation
Pressing on a control must not set off an action that cannot be taken back. Normally the action runs on release, so a person who pressed the wrong thing can slide off and let go.
/ What it requires
A pointer action has two moments: the down-event, when the button is pressed or the finger touches, and the up-event, when it is released. For any function operated with a single pointer, this criterion asks that at least one of four things holds. The down-event does not execute any part of the function. Or the function completes on the up-event and can be aborted before completion or undone after it. Or the up-event reverses whatever the down-event did, as with a preview that shows while pressed and disappears on release. Or completing on the down-event is essential.
People with tremors, low vision or cognitive disabilities often touch or click the wrong target. Activation on release gives them a built-in way out: they move the pointer off the target before letting go, and nothing happens. W3C counts functions that emulate a keyboard or keypad key press as essential, and names an on-screen piano and a game that depends on precise timing as other examples. The criterion covers content that interprets pointer actions, not the browser or assistive technology. The JavaScript click event fires on release, so native buttons and links with click handlers pass without extra work.
/ How pages fail it
- The close button of a dialog holding a long form listens for mousedown, pointerdown or touchstart, so a slip of the finger closes the dialog and the entries are lost.
- A delete icon in a list removes the row on pointerdown, with no confirmation and no undo.
- A menu item navigates on mousedown, so a person who presses it and slides away is taken to the page anyway.
- A send or buy button fires on touchstart, the moment a scrolling finger lands on it.
- In a sortable list, releasing a dragged item outside every drop zone still moves it, and there is no undo.
/ How to check it yourself
- Press and hold the mouse button on each control, or rest a finger on it, without releasing. Nothing irreversible should have happened yet.
- Still holding, move the pointer off the control and release it there. The action should not run.
- Where an action does run on press, look for a way back: the release reverses it, an undo control appears, or the function is essential, such as a key on an on-screen keyboard.
- For drag and drop, pick an item up and let go outside any drop target, or where it started. It should return to its place, or the move should be confirmed or undoable.
- In the developer tools, open the event listeners of suspect controls, or search the scripts for mousedown, pointerdown and touchstart handlers that do the work.
/ How to fix it
- Attach actions to the click event, which fires on release, instead of mousedown, pointerdown or touchstart.
- Build controls from button and a elements, so the browser applies its own activation on release.
- Where a press has to start something, such as a drag, complete it on pointerup only when the pointer is over a valid target, and put everything back on pointercancel or a release elsewhere.
- For destructive actions that run on press, add an undo control or a confirmation step.
- Keep the down-event for press-and-hold previews that the release removes, and for functions that are essential on press, such as the keys of an on-screen keyboard.
/ What our scanner checks
No automated check in our scan covers pointer cancellation. Whether an action fires on press or on release is decided in event handlers, which the scan does not read, and it never presses a control and slides off to see what happens. HTML_CodeSniffer flags inline onmousedown and ontouchstart attributes, but only as notices, and the scan keeps errors alone. A manual audit presses, slides off and releases on each control.
/ Who fails it, in our own measurements
The weekly index has no figures for this criterion, because none of the checks the site scan runs can test it. A person judges it, which is what a manual audit is for.
One page per body, measured by automated checks on a weekly schedule. Any body that has fixed something since the last sweep will show it at the next one, and every entity page carries a right of reply.
/ Questions about this criterion
Is it a WCAG failure to use mousedown or touchstart?
Not automatically. The criterion fails only when the down-event executes part of the function and none of the other conditions holds: no abort or undo, no reversal on release, and no essential reason. A press-and-hold preview that disappears on release is fine. A delete or close action on mousedown with no undo fails.
Does the JavaScript click event meet Pointer Cancellation?
Yes, in the usual case. W3C notes that the click event fires on release of the pointer, so a person who presses, slides off the control and lets go triggers nothing. That is why native buttons and links with click handlers meet the criterion without extra work.
When is activating on the down-event allowed?
When the outcome can be aborted or undone, when the release reverses it, or when completing on the down-event is essential. W3C treats functions that emulate a keyboard or numeric keypad key press as essential, and gives an on-screen piano and a game that depends on precise timing as further examples.
