diff --git a/src/components/Admin/common/RepositorySidebarOverlay/index.tsx b/src/components/Admin/common/RepositorySidebarOverlay/index.tsx index 35a458236..da4f21a43 100644 --- a/src/components/Admin/common/RepositorySidebarOverlay/index.tsx +++ b/src/components/Admin/common/RepositorySidebarOverlay/index.tsx @@ -7,6 +7,7 @@ import History, { type HistoryEntry, type HistoryEntryLocation } from "../../../../history/History"; +import { usePrevious } from "../../../../hooks/usePrevious"; import { digmaApi, useGetSpanInfoQuery @@ -70,18 +71,10 @@ export const RepositorySidebarOverlay = ({ ); const { resetInsights, resetAssets, resetGlobalErrors } = useStore.getState(); const dispatch = useAdminDispatch(); - const [history] = useState( - () => - new History([ - { - location: window.location, - state: { - spanCodeObjectId: currentSpanCodeObjectId, - tabLocation: currentTabLocation - } - } - ]) + const [history, setHistory] = useState( + () => new History([]) ); + const previousIsSidebarOpen = usePrevious(isSidebarOpen); const { data: spanInfo } = useGetSpanInfoQuery( { spanCodeObjectId: currentSpanCodeObjectId ?? "" }, @@ -172,17 +165,21 @@ export const RepositorySidebarOverlay = ({ resetInsights(); resetAssets(); resetGlobalErrors(); - history.clear(); - setCurrentTabLocation(initialTabLocation); setCurrentSpanCodeObjectId(undefined); + setCurrentTabLocation(initialTabLocation); onSidebarClose(); + }, [dispatch, onSidebarClose, resetAssets, resetGlobalErrors, resetInsights]); + + // Reset history on sidebar open + useEffect(() => { + if (!previousIsSidebarOpen && isSidebarOpen) { + setHistory(new History([])); + } }, [ - dispatch, - onSidebarClose, - resetAssets, - resetGlobalErrors, - resetInsights, - history + previousIsSidebarOpen, + isSidebarOpen, + currentSpanCodeObjectId, + currentTabLocation ]); useEffect(() => { diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/InsightIcon/index.tsx b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/InsightIcon/index.tsx index c3ac38630..871f66f95 100644 --- a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/InsightIcon/index.tsx +++ b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/InsightIcon/index.tsx @@ -27,7 +27,7 @@ export const InsightIcon = ({ return ( } - titlePlacement={"bottom"} + titlePlacement={"bottom-start"} type={tagType} content={