Skip to content

Commit 2c81a38

Browse files
patconclaude
andcommitted
fix: restore spotlight vote overlay re-selection after spotlight moves
onClick was stored in spotlightStackItems state, closing over a stale handleSpotlightStatementClick that still saw the old activeSpotlightStatementId. When the spotlight moved, the vote state was reset but the stale handler would detect activeStatementId === statementId and toggle off instead of on. Fix: store only data in state; inject onClick at render time so it always closes over the current handler with the current activeSpotlightStatementId. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent dc0c476 commit 2c81a38

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • src/components/convo-explorer

src/components/convo-explorer/App.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const App: React.FC<AppProps> = ({ testAnimation = false, kedroBaseUrl, i
7171

7272
// Spotlight mode state
7373
const [spotlightStackItems, setSpotlightStackItems] = React.useState<
74-
{ id: string | number; statement: { statement_id: number; txt: string }; variant: "agree" | "disagree"; onClick: () => void }[]
74+
{ id: string | number; statement: { statement_id: number; txt: string }; variant: "agree" | "disagree" }[]
7575
>([]);
7676
const [activeSpotlightStatementId, setActiveSpotlightStatementId] = React.useState<string | null>(null);
7777
const [spotlightPointVotes, setSpotlightPointVotes] = React.useState<(number | null)[]>([]);
@@ -495,7 +495,6 @@ export const App: React.FC<AppProps> = ({ testAnimation = false, kedroBaseUrl, i
495495
id: stat.tid,
496496
statement: { statement_id: Number(stat.tid), txt: String(commentTextMap[stat.tid] ?? "") },
497497
variant: (stat.repful_for === "agree" ? "agree" : "disagree") as "agree" | "disagree",
498-
onClick: () => handleSpotlightStatementClick(String(stat.tid)),
499498
}))
500499
);
501500
setActiveSpotlightStatementId(null);
@@ -505,7 +504,7 @@ export const App: React.FC<AppProps> = ({ testAnimation = false, kedroBaseUrl, i
505504
setSpotlightStackItems([]);
506505
}
507506
}, 400);
508-
}, [dataset, statements, handleSpotlightStatementClick]);
507+
}, [dataset, statements]);
509508

510509
// Vote stats calculation removed from App level - now handled in StatementExplorerDrawer
511510
// This avoids calculating stats for all statements when only group tab statements need them
@@ -902,7 +901,13 @@ export const App: React.FC<AppProps> = ({ testAnimation = false, kedroBaseUrl, i
902901

903902
{/* FloatingModalV2Stack - shows rep statements in spotlight mode */}
904903
{action === "spotlight" && (
905-
<FloatingModalV2Stack items={spotlightStackItems} isVisible={spotlightStackItems.length > 0} />
904+
<FloatingModalV2Stack
905+
items={spotlightStackItems.map(item => ({
906+
...item,
907+
onClick: () => handleSpotlightStatementClick(String(item.id)),
908+
}))}
909+
isVisible={spotlightStackItems.length > 0}
910+
/>
906911
)}
907912

908913
{/* FloatingModal - shows current statement in votes mode */}

0 commit comments

Comments
 (0)