phanq003 left a comment (openstreetmap/openstreetmap-website#7076)

> I'd like to see a clear discussion about alternative approaches. I'm 
> concerned that this is a lot of hard-to-test code and hard to maintain code.
> 
>     * Does rails (or hotwire, stimulus etc) offer anything similar?
> 
>     * Is there a ruby gem or standard javascript library that offers anything 
> similar?
> 
>     * If this is available in other text editors (e.g. Trix) or similar 
> situations (e.g. iD) can we re-use code from there?
> 
>     * Is there something
> 
> 
> It might be that what is presented here is the best approach, but I would 
> like to see it reasoned out.
> 
> Also, I'd like to see some reasoning as to which forms should get this 
> warning, and which ones should not. That helps decide whether this PR covers 
> enough of them, or if we can make it enabled by default (since someone adding 
> a new form on the website might not be aware this exists).

I haven't had time to research alternative libraries or existing 
implementations for this, so I can't really say whether there's a library in 
Rails/hotwire available.

My thinking behind this was that because the underlying logic (`beforeunload` 
and event.preventDefault()) is the browser-supported way for implementing 
warnings like this. At least from a user perspective I've seen similar popups 
on other websites so it would align with expected browser behaviour.

For the scope of forms, I would think it would mainly be attached to forms 
where users are creating or editing content over multiple fields, where 
navigating away would mean meaningful loss of work (e.g. diary entries, profile 
edits). This would then exclude more temporary forms like searches or login 
flows. If this was enabled by default, it could be a bit annoying to users when 
navigating away from the latter, and they'll could end up desensitised to it, 
which would probably reduce its effectiveness. Of course then there's still the 
problem of developers being aware it exists though.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7076#issuecomment-4460752626
You are receiving this because you are subscribed to this thread.

Message ID: 
<openstreetmap/openstreetmap-website/pull/7076/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to