Prevent page change when writing messages
Problem
Currently when I'm writing a message, I might click accidentally some link/bookmark or other button that changes the page. When I come back (via the browser back button) the message that I was writing is gone. It would be nice if the browser asked you if you really want to leave the page.
Description
No response
Screenshots
No response
Ref https://developer.chrome.com/docs/web-platform/page-lifecycle-api#the_beforeunload_event
Don't all modern browsers remember form state and restore it when you go back like that? Firefox certainly does.
Don't all modern browsers remember form state and restore it when you go back like that? Firefox certainly does.
On my computer FIrefox (v. 126.0.1, Linux Mint 21.3) doesn't remember the form state on OSM.org, but it remembers it on other sites (like Github)..
Well that's odd because I tested it on OSM before I wrote that comment and it worked for me.
You are right. After some fiddling with my extensions, it seems like the better-osm-org script is causing the problem (https://github.com/deevroman/better-osm-org/issues/24). Either way it would be nice to have a confirmation before navigating to another page or closing the tab.
The extension really affects the work of forms in Firefox (in Google Chrome 125 everything is fine)
However, in Google Chrome, form fields are reset when the page is reloaded:
https://github.com/openstreetmap/openstreetmap-website/assets/25708359/69f4a0ef-c8b7-4af2-a377-fda994555dda
Related issues: #4561, #4028 (same issue for notes and changeset comments)
I'm using Firefox v136 on Manjaro Linux and when in process of writing changeset comments and clicking some link elsewhere on that very page (still staying within osm.org), and then clicking back (technically the back button on my mouse), my in-progress comments are no longer there. This is even after starting firefox in safe-mode. I've never heard of better-osm script, so that isn't installed (pre safe-mode) either.
@b-jazz I have the same issue with changeset comments in Firefox. However, I think that's out of scope for this issue, which is specifically about user messages. I think losing your changeset comments is similar to #4028. (Note that that issue with changeset comments is not the same as #4561, linked above, because that issue focuses on switching object pagination screens).