> CloseWatcher API<p>> Chrome 120 brings the solution with CloseWatcher, a new API for directly listening and responding to close requests.<p>> watcher.addEventListener("close", () => document.querySelector("#sidebar").classList.remove("open"));<p>Couldn't they add an HTML attribute onCloseRequest?<p>Slightly related, I wish there was an attribute "onClickOutside" so we could close modals and dropdown menus without manually adding an event listener on the window and checking if the click wasn't inside the element.