demo · v134

CloseWatcher & Android Back

Light dismiss for <dialog> isn't just about backdrop clicks — it routes through the CloseWatcher infrastructure, which means Android's back gesture, Escape, swipe-back, and an explicit requestClose() all hit the same code path. This demo probes the surface and exposes the event order.

checking CloseWatcher & closedby support…
waiting…

closedby="any"

Backdrop click, Escape, Android back gesture — all dismiss. Most permissive.

closedby="closerequest"

Backdrop click ignored, but Escape, back gesture, and requestClose() still dismiss. Good middle ground.

closedby="none"

Forced choice — none of the dismissal gestures close this. Only the explicit button.

why this matters

On Android the back gesture is one of the dominant interaction patterns. Before CloseWatcher, dialogs that wanted to honour it had to listen for popstate, push history entries, and hand-roll Escape support — without consistent ordering when something else (a popover, a sheet, the page itself) was also in play. Light dismiss collapses all of that into a single cancel event with priority handled by the platform.

The closedby attribute is the developer-facing dial:

see also