From 5adad5eb9f66b2412b8ebcd9872028f26b1d6ae7 Mon Sep 17 00:00:00 2001 From: Jordan Andrzejczak Date: Mon, 28 Jul 2025 18:43:11 +0200 Subject: [PATCH] Prevent overwrite with prev state of search params Signed-off-by: Jordan Andrzejczak --- .../components/EntityLayout/EntityLayout.tsx | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx index bae1f7bd0c..65f904c285 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx @@ -361,7 +361,13 @@ export const EntityLayout = (props: EntityLayoutProps) => { UNSTABLE_extraContextMenuItems={UNSTABLE_extraContextMenuItems} UNSTABLE_contextMenuOptions={UNSTABLE_contextMenuOptions} onUnregisterEntity={() => setConfirmationDialogOpen(true)} - onInspectEntity={() => setSearchParams('inspect')} + onInspectEntity={() => { + setSearchParams(prev => { + const newParams = new URLSearchParams(prev); + newParams.set('inspect', ''); + return newParams; + }); + }} /> )} @@ -401,9 +407,21 @@ export const EntityLayout = (props: EntityLayoutProps) => { typeof InspectEntityDialog >['initialTab']) || undefined } - onSelect={newTab => setSearchParams(`inspect=${newTab}`)} + onSelect={newTab => + setSearchParams(prev => { + const newParams = new URLSearchParams(prev); + newParams.set('inspect', newTab); + return newParams; + }) + } open - onClose={() => setSearchParams()} + onClose={() => + setSearchParams(prev => { + const newParams = new URLSearchParams(prev); + newParams.delete('inspect'); + return newParams; + }) + } /> )}