Skip to content

Commit ffe4eec

Browse files
fix: stop the network-graph focus being cleared before the graph reads it
The redirect focus person was still landing on the top repeat offender even after the args/result coercion fix. Root cause was a state-clearing race: App clears requestedNetworkFocus in onInitialTabConsumed right after the dashboard mounts, and Dashboard passed that live prop straight to NetworkGraph. The focus flipped 6584 -> undefined on the very next render, NetworkGraph's effect re-ran, cancelled the focused fetch, and refetched without a focus -- selecting repeat_offenders[0]. Capture networkFocusPersonId into dashboard state once at mount (mirroring how activeTab captures initialTab) so clearing the App-level prop can no longer retrigger the graph.
1 parent 5c59a2d commit ffe4eec

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

frontend/src/components/Dashboard.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ export default function Dashboard({
274274
const [error, setError] = useState<string | null>(null);
275275
const [activeTab, setActiveTab] = useState<TabId>(initialTab ?? "overview");
276276
const [briefEmailStatus, setBriefEmailStatus] = useState<string | null>(null);
277+
// Capture the redirect focus person ONCE at mount, same as activeTab does
278+
// with initialTab. onInitialTabConsumed (below) clears the App-level prop
279+
// right after mount; if NetworkGraph read the live prop it would see the
280+
// focus flip to undefined and refetch without it, landing on the top repeat
281+
// offender instead of the person the officer asked about. Capturing here
282+
// pins the focus for this dashboard instance's lifetime.
283+
const [networkFocus] = useState<number | undefined>(networkFocusPersonId);
277284

278285
// Consume the redirect-requested tab once on mount so a later plain
279286
// re-entry to the dashboard (no new chat redirect) defaults to "overview".
@@ -642,7 +649,7 @@ export default function Dashboard({
642649

643650
{activeTab === "geo" && <GeoIntelligence user={user} />}
644651
{activeTab === "network" && (
645-
<NetworkGraph user={user} focusPersonId={networkFocusPersonId} />
652+
<NetworkGraph user={user} focusPersonId={networkFocus} />
646653
)}
647654
{activeTab === "crime" && <CrimeIntelligence user={user} />}
648655
{activeTab === "strategic" && <StrategicIntelligence user={user} />}

0 commit comments

Comments
 (0)