Whatās the best practice of warning users about UNSAVED CHANGES, before they leave the page?
Hi @bestbubbledev, I believe since users could of course use the browser navigation to leave a page, it is probably safest to use a script like the following & add the script inside a āRun Javascriptā action ONLY once an input value has been edited:
window.onbeforeunload = function() {
return "All unsaved data will be lost. Are you sure?";
};
When user has saved, remove this via:
window.onbeforeunload = null
Hi @bestbubbledev I saw you cross-posted this on twitter probably because my reply came in late.
As you said on twitter (and I totally relate) you would not want to create a workflow for every inputās change and then add the script to the page in each one of them.
I am working on a plugin for this now which allows you to add an id of a group and any inputs, multilines, dropdowns inside that group that change will add the script to the unload event.
Let me know what you think.
@bestbubbledev EDIT here is preview link for the plugin.
That is a great idea. Would it also be possible to trigger the warning on navigation inside the app, so e.g. when the user is not using the browser ābackā button, but a ābackā button inside my app?
I use autobinding a lot
Yes definitely one way to work around this (though sometimes not reliable), plus there are simply use cases where you do not want to auto-update data but need additional confirmation at the end of the form like a āSaveā button.
I have added a āGo to pageā action at the bottom and it works.
As the unload event of the window is triggered:
PREVIEW
EDITOR
Sounds great! And looks promising.
Hereās a quick feedback/question:
- When I click on āGo to indexā without changing input value, it doesnāt work.
- When I change the input value, do you cross-check it in the DB or the modal pops up no matter what?
- I presume you do not check the data in the DB. So can you add this to your script ā when I click on save button remove the input from the script?.. I assumed Iād add ID attributes to buttons as well? but not sure how would I associate each button to its respective input element.
Hope this is clear. Let me know if you need any clarifications from me.
Thanks for the quick feedback @bestbubbledev .
- Isnāt that what it should be doing? If no input was changed then do not issue a warning?
- + 3. At the moment the warning is simply issued as soon as you have modified any of the inputs. Next improvements will be:
(1) to add altered inputs to a list and remove an input from that list if the value is changed back to its original value
(2) provide an action to reset this list e.g. once save button is clicked. I guess this is what you are aiming for?
How the plugin currently works is that you can hand it the id of the group surrounding your inputs (could also be the page id), is that clear?
Thatās nice, what about single page apps where you hide/show groups without leaving the page? Would that also be possible?
I could add an extra action so that you can trigger the alert manually whenever you want.
Also I think it makes sense to expose a state which you can use in a condition on that action or anywhere else.
Wdyt?
Sounds good!
Hi @reger-alexander @bestbubbledev I have updated the plugin.
Any plans on when you will release the plugin?
Already submitted this for review. Will update here once approved.
@reger-alexander @bestbubbledev
Plugin is now live: Unsaved Changes Tracking & Alerts Plugin | Bubble
This is awesome. Meanwhile Iāve figured out a UX way of doing this but will def. take a look in the evening!
Interesting! What did you figure out UX wise?
Hey @jukoen thanks for building this! Just bought it and have it working but have a question -
I autobind the content in the inputs I have on the page that Iām using your plugin. I do this as an extra safety measure. What i noticed is that this creates an odd user experience. Say I type some new content into an input and I havenāt clicked out of the input so the autobind hasnāt saved the new content to the database yet. If i go to close the browser window your plugin comes to the rescue. But when I click ācancelā on the popup, the content autobinds to the database. But there is no trigger to āresetunsavedchangesā so even though the user sees a āYour changes have been saved ā alert, when they go to close the window again they get the popup āyou may have unsaved infoā¦ā
Do you have any thoughts on how to handle this? I have a save button that I use to reset unsaved changes element and that works, but the autobinding creates a weird ux. Thanks!
Hey @arensbpa, thanks for reaching out!
Would it be sufficient for you, in cases when you click ācancelā on the popup, the User keeps editing
event is fired?
From there you can then deselect the input (I added a new action), safe the inputās content via auto-binding & reset the unsaved changes element?
Hereās a quick demo.