From eb3a23ab03becd195bc9785c9c9ee71796a92330 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Sun, 22 Mar 2026 22:57:48 +0000 Subject: [PATCH] fix: resolve stale closure causing breadcrumbs to disappear on back-navigation (closes #2) The onClick handler in createPathSegment closed over the graphsPath variable from the render when the segment was created. By the time a breadcrumb was clicked (after further navigation), that closure was stale, so findIndex returned -1 and splice(0) wiped the entire breadcrumb array. Fix: use the functional updater form of setGraphsPath so findIndex runs against the current state rather than a stale snapshot. Co-Authored-By: Claude Sonnet 4.6 --- src/components/Graph.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/components/Graph.tsx b/src/components/Graph.tsx index 29f4ea0..5a8c284 100644 --- a/src/components/Graph.tsx +++ b/src/components/Graph.tsx @@ -264,12 +264,7 @@ const Graph = forwardRef { - const index = graphsPath.findIndex(p => p.key === pathSegmentId); - setGraphsPath(prev => { - prev.splice(index + 1); - - return [...prev]; - }); + setGraphsPath(prev => prev.slice(0, prev.findIndex(p => p.key === pathSegmentId) + 1)); selectGraphId(pathSegmentId); } } as BreadcrumbItemType; -- 2.47.3