diff --git a/.changeset/two-bars-warn.md b/.changeset/two-bars-warn.md new file mode 100644 index 0000000000..beef36201f --- /dev/null +++ b/.changeset/two-bars-warn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Fixed bug in EntityLayout that caused wiping existing query parameters when opening the InspectEntityDialog. 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; + }) + } /> )}