budibase icon indicating copy to clipboard operation
budibase copied to clipboard

Refresh State in Parent from Child Modal

Open melohagan opened this issue 3 years ago • 8 comments
trafficstars

Discussed in https://github.com/Budibase/budibase/discussions/5524

... In particular because the 'add specialty' screen opens in a modal, I couldn't find a way to trigger a navigation after closing the modal. This would have effectively allowed a refresh of the page, with the default values of the form saved in App State: https://docs.budibase.com/docs/app-state

It might be nice to have an optional redirect URL for the close modal action. I've suggested that here: https://github.com/Budibase/budibase/discussions/1176#discussioncomment-2614757

Another discussion with the same issue: https://github.com/Budibase/budibase/discussions/5626

Need a way to update state from a modal screen, or as suggested a redirect option after the modal has been closed.

melohagan avatar Apr 28 '22 09:04 melohagan

Need a way to update state from a modal screen

State updates are already proxied back from screens in modals - so that's usually the best solution if you need to pass back some value from the modal that isn't saved as data. i.e. if you use update state from a screen in a modal, the state is updated on the parent immediately as well.

Can keep this open as a feature request to add an option for redirecting on closing a screen modal though.

aptkingston avatar Apr 28 '22 12:04 aptkingston

That's cool! I think then it's the on change feature that's needed so that updating the state updates the fields.

The redirect idea was really just another work around for this, but it may have some other use cases, but not a priority. Haven't seen anyone else ask for it specifically.

melohagan avatar Apr 28 '22 12:04 melohagan

Actually, you can't simply use the on change, because the field you're trying to update is in a different screen. The same issue has popped up here:

https://github.com/Budibase/budibase/discussions/6181

melohagan avatar Jun 06 '22 13:06 melohagan

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Aug 10 '22 04:08 stale[bot]

Any progress on this issue?

fachebot avatar Sep 07 '22 10:09 fachebot

I'm also interested in this. I want to close a modal and for it to trigger the 'Refresh Data Provider' action. Can't seem to figure out a way to do this at the moment natively in Budibase.

ghost avatar Sep 13 '22 08:09 ghost

@adamjdavies if you've edited data inside the modal that is part of the same datasource as the parent page, then you shouldn't need to manually refresh the data provider - it should do it automatically. This won't work if you're using a rest API as your datasource but should work for anything else (including custom queries).

Maybe you have other reasons for needing a refresh, but if you're editing data in the same datasource then this should work automatically and would be a bug if it isn't.

aptkingston avatar Sep 13 '22 08:09 aptkingston

@aptkingston - all of my data is being pulled from an Airtable query, so I need to update the datasource each time a change is made. Therefore, I need some way of triggering 'Refresh Data Provider' action when either the modal is closed or based off of some trigger.

The ability to trigger page actions based on a state change or other conditions is something I think Budibase is missing.

ghost avatar Sep 13 '22 09:09 ghost