Skip to content

Commit d57e468

Browse files
committed
fix: Add window width tracking to optimize chart resizing behavior
1 parent ae3d411 commit d57e468

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

dashboard/src/components/statistics/statistics-charts.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function StatisticsCharts({ data, isLoading, error, selectedServe
2323
// Add state for chart refresh
2424
const [chartRefreshKey, setChartRefreshKey] = useState(0)
2525
const resizeTimeoutRef = useRef<NodeJS.Timeout>()
26+
const lastWindowWidthRef = useRef<number>(typeof window !== 'undefined' ? window.innerWidth : 0)
2627

2728
// Only fetch nodes for sudo admins
2829
const { isLoading: isLoadingNodes, error: nodesError } = useGetNodesSimple({ all: true }, {
@@ -46,6 +47,13 @@ export default function StatisticsCharts({ data, isLoading, error, selectedServe
4647

4748
// Handle resize events to refresh charts
4849
const handleResize = useCallback(() => {
50+
const currentWidth = window.innerWidth
51+
if (currentWidth === lastWindowWidthRef.current) {
52+
return
53+
}
54+
55+
lastWindowWidthRef.current = currentWidth
56+
4957
if (resizeTimeoutRef.current) {
5058
clearTimeout(resizeTimeoutRef.current)
5159
}

0 commit comments

Comments
 (0)