forms icon indicating copy to clipboard operation
forms copied to clipboard

Implement warning when leaving an unsubmitted form

Open Chartman123 opened this issue 3 years ago • 5 comments

Fixes #319 by adding a warning

Signed-off-by: Christian Hartmann [email protected]

Chartman123 avatar Aug 23 '22 18:08 Chartman123

@jotoeri any ideas why the custom message isn't shown in the window.confirm() dialog?

Chartman123 avatar Aug 23 '22 18:08 Chartman123

Seems like just confirm should work. But to be honest, i currently can't tell you exactly, why. :laughing:

https://github.com/nextcloud/forms/blob/6c257edeea2231aeb55f1b62ab85dbb49d6ecef7/src/components/AppNavigationForm.vue#L207

jotoeri avatar Aug 26 '22 16:08 jotoeri

@jotoeri Tried it with just confirm() but doesn't work either... Even with static text. Did just research and it seems that it doesn't accept custom text for the onbeforeunload event

Chartman123 avatar Aug 26 '22 18:08 Chartman123

Ok, sorry @Chartman123 i checked it once before quickly, but i definitely have not time to get into detail currently. Needs probably to be postponed.

jotoeri avatar Sep 14 '22 14:09 jotoeri

No problem, I think the design parts are more important for 3.0 than this here :)

Chartman123 avatar Sep 14 '22 15:09 Chartman123

confirm and alert are not allowed within beforeunload. Also all browser dropped support for custom messages, so you only can use the default one.

Chrome removed support for custom message in ver 51
Opera removed support for custom message in ver 38
Firefox removed support for custom message in ver 44.0
Safari removed support for custom message in ver 9.1

susnux avatar Dec 28 '22 13:12 susnux

Yes, that's true. I'm currently trying to move the warning to a NcModal like in the Cookbook app... This should at least work for leaving a form without closing the window/tab.

Chartman123 avatar Dec 28 '22 13:12 Chartman123

@susnux Thanks for your input :) I'm also planning to move the warning to a modal. If you want, you can help me there. Everytime I tried it ended up being even worse 😆

Chartman123 avatar Jun 24 '23 21:06 Chartman123

@susnux I think I got this working as expected right now. I think we should merge this without the modal, so that we can take it as a basis for @hamza221's PR regarding the local storage.

Chartman123 avatar Sep 30 '23 21:09 Chartman123