I hate when I hit back, but instantly redirect to the same page. This is so frustrating when it happens. And it happens even on major sites. (Microsoft’s official community “answers” forums have given me this issue lately. Fills up search results and then traps you there)
Briefly, the user may need to press back a couple times in order to escape, but the maximum number of presses needed is bounded and is dependent on how much the user interacts with the page. Of note, closing the tab bypasses this API entirely, at least according to that page.
Also, GitHub team, could you make your app better? It has so many little annoyances.
The funny/sad thing is the folks adding this functionality are probably reading my comment. You should be ashamed of yourselves.
> Chrome 120 brings the solution with CloseWatcher, a new API for directly listening and responding to close requests.
> watcher.addEventListener("close", () => document.querySelector("#sidebar").classList.remove("open"));
Couldn't they add an HTML attribute onCloseRequest?
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.
If you use popover="", you get the kind of functionality you're discussing for free. For <dialog>, the discussion is in progress and reaching a conclusion: https://github.com/whatwg/html/issues/9373
How about my User Agent working for me instead? and doing exactly what I want and not some web page?