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.
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:
any— backdrop, Escape, back, requestClose() all close (good for non-blocking sheets).closerequest— Escape, back, requestClose() close but backdrop click does not (good for forms you don't want to lose by accident).none— only explicit close (good for required choices).