diff --git a/.changeset/loud-drinks-juggle.md b/.changeset/loud-drinks-juggle.md new file mode 100644 index 0000000000..d667a5115c --- /dev/null +++ b/.changeset/loud-drinks-juggle.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): call route modal onClose only on route change diff --git a/packages/admin/dashboard/src/components/modals/route-modal-form/route-modal-form.tsx b/packages/admin/dashboard/src/components/modals/route-modal-form/route-modal-form.tsx index 69ececbcdb..4328f9f4df 100644 --- a/packages/admin/dashboard/src/components/modals/route-modal-form/route-modal-form.tsx +++ b/packages/admin/dashboard/src/components/modals/route-modal-form/route-modal-form.tsx @@ -35,22 +35,22 @@ export const RouteModalForm = ({ const isSearchChanged = currentLocation.search !== nextLocation.search if (blockSearch) { - const ret = isDirty && (isPathChanged || isSearchChanged) + const shouldBlock = isDirty && (isPathChanged || isSearchChanged) - if (!ret) { + if (isPathChanged) { onClose?.(isSubmitSuccessful) } - return ret + return shouldBlock } - const ret = isDirty && isPathChanged + const shouldBlock = isDirty && isPathChanged - if (!ret) { + if (isPathChanged) { onClose?.(isSubmitSuccessful) } - return ret + return shouldBlock }) const handleCancel = () => {