Skip to content

Commit a7c3225

Browse files
committed
Fix sidebar tab selection
1 parent 36c43ea commit a7c3225

File tree

2 files changed

+17
-20
lines changed
  • src/components
    • Admin/common/RepositorySidebarOverlay
    • Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/InsightIcon

2 files changed

+17
-20
lines changed

src/components/Admin/common/RepositorySidebarOverlay/index.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import History, {
77
type HistoryEntry,
88
type HistoryEntryLocation
99
} from "../../../../history/History";
10+
import { usePrevious } from "../../../../hooks/usePrevious";
1011
import {
1112
digmaApi,
1213
useGetSpanInfoQuery
@@ -70,18 +71,10 @@ export const RepositorySidebarOverlay = ({
7071
);
7172
const { resetInsights, resetAssets, resetGlobalErrors } = useStore.getState();
7273
const dispatch = useAdminDispatch();
73-
const [history] = useState(
74-
() =>
75-
new History<RepositorySidebarHistoryState>([
76-
{
77-
location: window.location,
78-
state: {
79-
spanCodeObjectId: currentSpanCodeObjectId,
80-
tabLocation: currentTabLocation
81-
}
82-
}
83-
])
74+
const [history, setHistory] = useState(
75+
() => new History<RepositorySidebarHistoryState>([])
8476
);
77+
const previousIsSidebarOpen = usePrevious(isSidebarOpen);
8578

8679
const { data: spanInfo } = useGetSpanInfoQuery(
8780
{ spanCodeObjectId: currentSpanCodeObjectId ?? "" },
@@ -172,17 +165,21 @@ export const RepositorySidebarOverlay = ({
172165
resetInsights();
173166
resetAssets();
174167
resetGlobalErrors();
175-
history.clear();
176-
setCurrentTabLocation(initialTabLocation);
177168
setCurrentSpanCodeObjectId(undefined);
169+
setCurrentTabLocation(initialTabLocation);
178170
onSidebarClose();
171+
}, [dispatch, onSidebarClose, resetAssets, resetGlobalErrors, resetInsights]);
172+
173+
// Reset history on sidebar open
174+
useEffect(() => {
175+
if (!previousIsSidebarOpen && isSidebarOpen) {
176+
setHistory(new History<RepositorySidebarHistoryState>([]));
177+
}
179178
}, [
180-
dispatch,
181-
onSidebarClose,
182-
resetAssets,
183-
resetGlobalErrors,
184-
resetInsights,
185-
history
179+
previousIsSidebarOpen,
180+
isSidebarOpen,
181+
currentSpanCodeObjectId,
182+
currentTabLocation
186183
]);
187184

188185
useEffect(() => {

src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/InsightIcon/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const InsightIcon = ({
2727
return (
2828
<Tag
2929
title={<InsightIconTooltip {...{ severity, impact, criticality }} />}
30-
titlePlacement={"bottom"}
30+
titlePlacement={"bottom-start"}
3131
type={tagType}
3232
content={
3333
<s.InsightIconContainer>

0 commit comments

Comments
 (0)