63
votes
Added a confirmation prompt if you're leaving a page with something "unfinished"
This has been requested a number of times, sorry for all the lost comments in the meantime.
The site should now ask you to confirm if you try to leave a page with an "unfinished" topic, comment, or message. This includes starting to write new ones, but also covers the forms for editing a post. It should only trigger if you actually make any changes, so if you click "Edit" on a comment/topic, but don't edit it at all (or do, and then change the text back to what it was originally), you shouldn't get a confirmation when you leave the page.
Please let me know if you notice any issues or strange behaviors with this.
Yay! As someone who constantly fat fingers while typing on my mobile, this will save a lot of my work!
I actually kind of liked it without it. So many times I decided to abandon a comment and was somewhat happy I didn't need to confirm
I'm sorta of the same opinion. I abandon half-written comments somewhat often, and the popup is fairly annoying if you're navigating away from the page intentionally.
OTOH, I fully understand why people would want this feature. Can we maybe get a toggle for this?
Edit: I've been saved by this feature once now, so I'll never again badmouth it. I forgot that the
v
andw
keys are right next to each other on the dvorak layout, so it's really easy to close the window when you meant to paste.I don't think it's worth adding a setting. You can just hit Enter or click the button when it happens, it's a bit inconvenient but I can't imagine it's more than a few seconds per day in total.
I don't really want to start adding settings for every tiny thing. That's how we'll end up with a settings page with 800 checkboxes to disable every minor aspect of site behavior, and the code will be far harder to work with because you always have to remember to check the relevant user setting(s) before doing anything.
If it really bothers you, there are other options for disabling it. For example, if you're using Firefox, you can open
about:config
and change the settingdom.disable_beforeunload
totrue
. That will disable these kind of "leaving the page" confirmations on all sites. I imagine there are also add-ons, tampermonkey/greasemonkey scripts, etc. that can do this pretty easily as well.Yeah I suppose that's the best way to do it since it bugs me on reddit too.
This is definitely one of those features where it's better to save someone from inadvertently losing a giant comment than it is to make dropping the comment ridiculously easy. If it's a matter of favoring explicit action over losing potentially half an hour of work writing up a great comment, the former is definitely preferred, especially when given the goals of Tildes.
As Deimos noted as well, there's a usability concern when you add a toggle for everything on the site, and this is one of those things that doesn't really make sense to put a toggle in for.
I don't have the time today, but if you'd like then I'll look into writing up a quick and dirty tampermonkey script sometime in the next few days if I have the time and no one beats me to the punch. Odds are it'll end up doing just a tiny bit of DOM manipulation to remove a form attribute, so it should be short, simple, and easy for you to review to make sure it's not doing anything you're not expecting.
All it would need to be is looking for any
<form>
withdata-js-confirm-leave-page-unsaved
attribute on it, and removing that attribute.I think this might be a good addition to Tildes Extended. Not sure who maintains it, and I'm ignorant enough about git that I don't know how to properly propose such an idea, but just throwing it out there that it's a feature at least a couple people want, and it should be pretty trivial to implement.
@crius does, not that tagging pings them or anything.
I figured it would be something like that. Thanks for letting me know which attribute it is!
Thank god. MY SAVIOR
I just tested it out now and it works perfectly in Firefox. May there be no more comments lost to the void!
Thank you!
Confirming that it works on desktop safari and chrome.
This just saved me about an hour ago, thanks for this!
Hmm...pressing the back button when typing comments in Endless Browser on iOS doesn’t give any pop ups. Nor does exiting.
Hmm, I don't know anything about Endless Browser. From a quick glance it seems to include a fair amount of javascript-blocking and similar features, so it's possible that it's blocking the javascript needed for this function. I don't know if might have a setting to allow it, but it might be labeled something like "block beforeunload events" if it does.
I get pop ups when hitting the cancel button, so it’s probably not that (there’s no setting for that anyways.) Also checked in Safari, and it behaves the same. I’m guessing it’s a WebKit feature to prevent malicious sites from abusing pop ups.
Huh, looks like Apple disabled that event on iOS: https://stackoverflow.com/questions/4127621/is-there-any-way-to-use-window-onbeforeunload-on-mobile-safari-for-ios-devices
I'll look into some of the alternatives/suggestions.