Skip to content

Commit 972d7d4

Browse files
committed
fix: move Suspense boundaries to per-chart to prevent React hideInstance scroll collapse
React's Suspense hideInstance sets display:none!important on the entire chartStack div during concurrent transitions, collapsing body height and clamping scroll to 0. Moving Suspense inside each LazyChart/chart surface scopes this behavior to individual chart containers.
1 parent 3701645 commit 972d7d4

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/components/ReportPageLayout.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,14 @@ export function ReportPageLayout({ schema, allowedReportTypes, metricOptions }:
585585
|| activeReport?.type === REPORT_TYPES.COPILOT_SEAT_ACTIVITY
586586
|| activeReport?.type === REPORT_TYPES.ENTERPRISE_MEMBERS;
587587
return (
588-
<Suspense fallback={null}>
589-
{/* Use visibility:hidden (not display:none) during transient empty states
590-
so the chart DOM keeps its layout height and scroll position is preserved. */}
588+
/* No outer Suspense here — each LazyChart has its own Suspense boundary
589+
so React's hideInstance only affects individual charts, not the entire stack. */
591590
<div className={styles.chartStack} key={activeReportIndex} style={hasData ? undefined : { visibility: 'hidden' }}>
592591
{!isFlatReport && (
593592
<div className={styles.chartSurface}>
594-
<TimeSeriesChart metricOptions={chartMetricOptions} />
593+
<Suspense fallback={null}>
594+
<TimeSeriesChart metricOptions={chartMetricOptions} />
595+
</Suspense>
595596
</div>
596597
)}
597598
<LazyChart className={styles.chartSurface}>
@@ -606,7 +607,6 @@ export function ReportPageLayout({ schema, allowedReportTypes, metricOptions }:
606607
<SankeyChart hierarchy={schema.sankeyHierarchy} metric={activeMetric} />
607608
</LazyChart>
608609
</div>
609-
</Suspense>
610610
);
611611
})()}
612612

src/components/charts/LazyChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react';
1+
import { Suspense, useCallback, useEffect, useRef, useState, type ReactNode } from 'react';
22

33
interface LazyChartProps {
44
children: ReactNode;
@@ -59,7 +59,7 @@ export function LazyChart({ children, className, minHeight = 400 }: LazyChartPro
5959
className={className}
6060
style={{ minHeight, contain: visible ? undefined : 'content' }}
6161
>
62-
{visible ? children : null}
62+
{visible ? <Suspense fallback={null}>{children}</Suspense> : null}
6363
</div>
6464
);
6565
}

0 commit comments

Comments
 (0)