openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.09k stars 907 forks source link

Prevent page change when writing messages #4898

Open Dimitar5555 opened 3 weeks ago

Dimitar5555 commented 3 weeks ago

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

HolgerJeromin commented 3 weeks ago

Ref https://developer.chrome.com/docs/web-platform/page-lifecycle-api#the_beforeunload_event

tomhughes commented 3 weeks ago

Don't all modern browsers remember form state and restore it when you go back like that? Firefox certainly does.

Dimitar5555 commented 3 weeks ago

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)..

tomhughes commented 3 weeks ago

Well that's odd because I tested it on OSM before I wrote that comment and it worked for me.

Dimitar5555 commented 3 weeks ago

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.

deevroman commented 3 weeks ago

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

mmd-osm commented 3 weeks ago

Related issues: #4561, #4028 (same issue for notes and changeset comments)