I'm building an app and I want to re-fetch data when the query confirmation modal is cancelled.
The workflow is as follows.
The user toggles a switch, which triggers a query.
The query shows a confirmation modal asking the user to confirm the change (The value of the switch is already toggled on the client side).
User clicks "Ok" on the confirmation modal
The query makes an API call to toggle the value on the server side
Regardless of query success or failure, I show a success/failure notification and refetch data to show the updated value.
The values shown are in sync with what's on the server
However workflow breakdown when the user presses "Cancel" instead in the query trigger modal. The switch has already toggled the value in the client side but I have no way to trigger a refresh. Now the values are out of sync.
The first thing that comes to mind is to use a modal instead of the query conformation.
Add your two buttons, Ok, Cancel and handle each with appropriate handlers.
However, with a modal you will get a third option which is the user just closing the modal. Use the modal's close event to capture that eventuality and handle as you see fit.
Is there a way to keep the toggle button and handle the 'Cancel' behaviour? I don't want to change the toggle to action buton from a modal, as suggested in this response. Is there a way to refresh the state of the toggle when pressing cancel in confirmation modal?
Hi @SS_SMP we have a feature request to add an event handler that will trigger when a query confirmation is canceled, but currently this isn't supported I'll add your +1 to the feature request and will follow up here if our team ships this feature