diff --git a/.changeset/thirty-rice-brush.md b/.changeset/thirty-rice-brush.md new file mode 100644 index 000000000000..25d7c2c7fbbc --- /dev/null +++ b/.changeset/thirty-rice-brush.md @@ -0,0 +1,5 @@ +--- +"@refinedev/antd": major +--- + +in queryoptions made the keepPreviousData as false so that user do not see the data of previous modal on opening the new one. diff --git a/packages/antd/src/hooks/form/useForm.ts b/packages/antd/src/hooks/form/useForm.ts index 1a737df11d96..4d91fe012253 100644 --- a/packages/antd/src/hooks/form/useForm.ts +++ b/packages/antd/src/hooks/form/useForm.ts @@ -252,7 +252,10 @@ export const useForm = < onLiveEvent, invalidates, undoableTimeout, - queryOptions, + queryOptions: { + ...queryOptions, + keepPreviousData: false, + }, createMutationOptions, updateMutationOptions, id: idFromProps, diff --git a/packages/antd/src/hooks/form/useModalForm/useModalForm.ts b/packages/antd/src/hooks/form/useModalForm/useModalForm.ts index 31db0d24215a..0d8c7ade9345 100644 --- a/packages/antd/src/hooks/form/useModalForm/useModalForm.ts +++ b/packages/antd/src/hooks/form/useModalForm/useModalForm.ts @@ -281,7 +281,6 @@ export const useModalForm = < "Are you sure you want to leave? You have unsaved changes.", ), ); - if (warnWhenConfirm) { setWarnWhen(false); } else { @@ -298,6 +297,7 @@ export const useModalForm = < if (typeof showId !== "undefined") { setId?.(showId); } + const needsIdToOpen = action === "edit" || action === "clone"; const hasId = typeof showId !== "undefined" || typeof id !== "undefined"; if (needsIdToOpen ? hasId : true) {