diff --git a/static/app/views/issueDetails/streamline/eventNavigation.tsx b/static/app/views/issueDetails/streamline/eventNavigation.tsx
index 1bf953d2c2608b..f756a91737a2f9 100644
--- a/static/app/views/issueDetails/streamline/eventNavigation.tsx
+++ b/static/app/views/issueDetails/streamline/eventNavigation.tsx
@@ -342,8 +342,13 @@ function EventNavigationLink({
config?.initialCollapse ?? false
);
return (
-
+
);
}
diff --git a/static/app/views/issueDetails/streamline/foldSection.tsx b/static/app/views/issueDetails/streamline/foldSection.tsx
index f9a32f70291596..e46e85ca89e418 100644
--- a/static/app/views/issueDetails/streamline/foldSection.tsx
+++ b/static/app/views/issueDetails/streamline/foldSection.tsx
@@ -4,6 +4,7 @@ import {
Fragment,
useCallback,
useLayoutEffect,
+ useRef,
useState,
} from 'react';
import styled from '@emotion/styled';
@@ -13,6 +14,7 @@ import InteractionStateLayer from 'sentry/components/interactionStateLayer';
import {IconChevron} from 'sentry/icons';
import {space} from 'sentry/styles/space';
import {trackAnalytics} from 'sentry/utils/analytics';
+import mergeRefs from 'sentry/utils/mergeRefs';
import useOrganization from 'sentry/utils/useOrganization';
import {useSyncedLocalStorageState} from 'sentry/utils/useSyncedLocalStorageState';
import type {SectionKey} from 'sentry/views/issueDetails/streamline/context';
@@ -53,7 +55,6 @@ export const FoldSection = forwardRef(function Fo
sectionKey,
initialCollapse = false,
preventCollapse = false,
- ...props
},
forwardedRef
) {
@@ -64,6 +65,31 @@ export const FoldSection = forwardRef(function Fo
getFoldSectionKey(sectionKey),
initialCollapse
);
+ const hasAttemptedScroll = useRef(false);
+
+ const scrollToSection = useCallback(
+ (element: HTMLElement | null) => {
+ if (!element || !navScrollMargin || hasAttemptedScroll.current) {
+ return;
+ }
+ // Prevent scrolling to element on rerenders
+ hasAttemptedScroll.current = true;
+
+ // scroll to element if it's the current section on page load
+ if (window.location.hash) {
+ const [, hash] = window.location.hash.split('#');
+ if (hash === sectionKey) {
+ if (isCollapsed) {
+ setIsCollapsed(false);
+ }
+
+ // Delay scrollIntoView to allow for layout changes to take place
+ setTimeout(() => element?.scrollIntoView(), 100);
+ }
+ }
+ },
+ [sectionKey, navScrollMargin, isCollapsed, setIsCollapsed]
+ );
useLayoutEffect(() => {
if (!sectionData.hasOwnProperty(sectionKey)) {
@@ -92,8 +118,7 @@ export const FoldSection = forwardRef(function Fo
return (