From 3fb4d5beb05510fc3727199f0387fae5c8642520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Sun, 11 May 2025 19:52:12 +0200 Subject: [PATCH] fix(dashboard): call route modal onClose only on route change (#12383) --- .changeset/loud-drinks-juggle.md | 5 +++++ .../modals/route-modal-form/route-modal-form.tsx | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/loud-drinks-juggle.md 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 = () => {