Closing modal after save, gives warning that you are leaving the page.
I have a modal like this:
When I hit save, it is giving the "Are you sure you want to leave? You have unsaved changes." alert despite actually saving.
3 Replies
Hi @Jonathan. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The issue you're encountering is related to the
warnWhenUnsavedChanges
property and how the onFinish
function is being handled in your modal form. According to the documentation, the onFinish
function from formProps
will handle closing the modal internally and is important for features like the unsaved changes notifier.
To resolve this issue, you should ensure that you are using the onFinish
function from formProps
correctly and avoid manually calling close()
after onFinish
. Here is the corrected version of your code:
In this updated code, the handleFinish
function awaits the onFinish
function from formProps
, which will handle closing the modal and other necessary actions internally. This should prevent the "Are you sure you want to leave? You have unsaved changes." alert from appearing after saving.
For more information, you can refer to the useModalForm documentation (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-modal-form/#close).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@697199226802929705> kapa.ai is still learning and improving, please let us know how it did by reacting below
fair-rose•7d ago
also why on this form would there be a delay on entering data in the name field