This would also be a good candidate for building an element plugin in javascript. If anyone is interested in learning to build bubble plugins, I think this one would be pretty easy to start with. I’m imagining an invisible element with two dynamic properties, “block the user from leaving?”, and “message”.
Instructions on how to do it in javascript are here: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
And instructions on how to build plugins in Bubble are here: https://manual.bubble.is/building-plugins/building-elements.html
The one potential gotcha with this is that Bubble already sets window.onbeforeunload (so that we can pop something up if a user is running a workflow when they try to leave), so I’d make sure to wait til Bubble sets it, and then do something like this:
var old_beforeunload = window.onbeforeunload;
window.onbeforeunload = function() {
//If we want to block them, return something
//....
//Otherwise, run the Bubble code:
return old_beforeunload();
}