Budibase / budibase

Low code platform for building business apps and workflows in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s, and more 🚀
https://budibase.com
Other
21.24k stars 1.44k forks source link

13792 add settings in nav links to prompt user before navigating away #13879

Closed ConorWebb96 closed 3 days ago

ConorWebb96 commented 4 weeks ago

Description

Added a confirmation utility function that shows a prompt that must be confirmed before a user can navigate away.

In some cases users may not want to accidentally navigate away from there page as it looses any data that they have added to the form fields. With this feature the intent is to avoid that from happening if you configure your screens correctly.

Addresses

Screenshots

Screen setting showcase

Screenshot 2024-06-07 at 13 34 52

Confirmation Modal

Screenshot 2024-06-07 at 13 35 27

Launchcontrol

Added the option of a modal that must be confirmed if the user wishes to change screens. (Prevents data loss if configured for users.)

aptkingston commented 3 weeks ago

Had a chat with @ConorWebb96 about this.

I've pushed up code to https://github.com/Budibase/budibase/tree/navigation-confirmation which allows for intercepting navigation requests at a very low level and preventing them (if desired) without causing any re-renders, meaning you could do thinks like prevent losing work in an unsaved form. This intercepts all navigation events - clicking a nav link, using a normal link component, button actions, browser back and forward buttons etc.

I've designed that in a way that components can specify when and if they want to block navigation - my reasoning being that you don't want to always warn when leaving a screen. It's always conditional on a component being in a certain state, such as only after you've made a change to a form, but not if you haven't made a change.

I'll flesh that out into a real PR at some stage, but we need to decide how to integrate it with components.

My preference is adding it as settings to certain components (just form for now?) as a checkbox ("Confirm discarding unsaved changes" or something), then a checkbox if that is ticked for the prompt (to avoid hardcoded english).

We would then only conditionally prompt users if they've actually modified the form, but not annoy them if they haven't changed it.

That can then be rolled out to whatever other components which make sense to have it.

shogunpurple commented 3 days ago

Can we close this @ConorWebb96 based on @aptkingston comment?