ModalCloseWatcher can be used to listen to a set of signals that might correspond to closing an app-modal dialog. Once a ModalCloseWatcher is created, it will fire an event when a user presses the Esc key on desktop, or a system-provided back button on mobile.
This proposal has potential overlap with the <popup> proposal (I2P), as the explainer notes. We believe prototyping ModalCloseWatcher is valuable, but when it comes time to potentially ship, we'll need to evaluate whether ModalCloseWatcher is worth exposing independently from <popup>.
Modals are UI components that are layered on top of all other content and take interaction focus. An important common feature of these modals is that they are designed to be easy to close, with a uniform interaction mechanism for doing so. Typically, this is the Esc key on desktop platforms, and the back button on some mobile platforms (notably Android).
Currently, web developers have no good way to handle these close signals for their own modals. This is especially problematic on Android devices, where the back button is the traditional close signal.
This API is designed to have an interoperable surface for web developers, to help them avoid platform-specific code. So, if it were implemented across browsers, it would be a positive for interoperability. We have not yet asked for signals, however.
From a compatibility perspective, this feature has a relatively simple API surface that allows us to swap out the underlying behavior, which reduces the likelihood of needing breaking changes in the future.
Gecko: No signal
Edge: No signal
WebKit: No signal
Web developers: Positive signals. We have talked to a couple control libraries who are interested in solving this problem and will test our prototype to see if it is a good solution.