The CloseWatcher interface allows a custom UI component with open and close semantics to respond to device-specific close actions in the same way as a built-in component . It enables developers to handle close requests by firing cancel and close events, which can be managed using methods like requestClose() and close() .
Specifically:
- `requestClose()`: Fires a
cancelevent. If not canceled viaEvent.preventDefault(), it fires acloseevent and then deactivates the watcher as ifdestroy()was called . - `close()`: Skips the
cancelevent logic entirely and immediately fires thecloseevent, also deactivating the watcher . - Grouping Behavior: If multiple
CloseWatcherinstances are created without user activation, they are grouped together; a single close request will close all of them .
This information is drawn from the MDN Web Docs reference for the CloseWatcher interface and its methods. Since web platform features evolve, check the current official documentation for the latest implementation details.