warnWhenUnsavedChanges is getting asked twice

I have to click "Cancel" or "Okay" twice when warnWhenUnsavedChanges is being active on my Modal form via the useModalForm hook
3 Replies
kapa.ai
kapa.ai5mo ago
Hi @script4559. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The extracts provided do not contain information about the warnWhenUnsavedChanges prop being asked twice. However, the warnWhenUnsavedChanges prop is used to show a warning when the user tries to leave the page with unsaved changes. It is false by default and can be set to true to enable this feature. This is done to prevent the user from accidentally leaving the page. Here is how you can use it in your useModalForm hook:
const modalForm = useModalForm({
warnWhenUnsavedChanges: true,
});
const modalForm = useModalForm({
warnWhenUnsavedChanges: true,
});
For more information, you can refer to the Refine documentation (https://refine.dev/docs). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@584066183989428345> kapa.ai is still learning and improving, please let us know how it did by reacting below
adverse-sapphire
adverse-sapphire5mo ago
help admin. this is how I open the modal
const handleAddStage = () => {
replace("stages/create");
};
const handleAddStage = () => {
replace("stages/create");
};
and this is my onCancel function:
const handleClose = (state?: string) => {
if (state === "save")
invalidate({
invalidates: ["all"],
resource: `/...`,
});
close();
go({
to: `/...`,
});
};
const handleClose = (state?: string) => {
if (state === "save")
invalidate({
invalidates: ["all"],
resource: `/...`,
});
close();
go({
to: `/...`,
});
};