From 7f38cbab73313082b4fa442239a681a2bd82a437 Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 17 Mar 2026 23:23:52 +0100 Subject: [PATCH] Preserve stat block panel collapsed state on turn advance Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/src/App.tsx | 4 ++-- apps/web/src/hooks/use-side-panel-state.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index fe73588..94805c2 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -210,9 +210,9 @@ export function App() { encounter.combatants[encounter.activeIndex]?.creatureId; useEffect(() => { if (activeCreatureId && sidePanel.panelView.mode === "creature") { - sidePanel.showCreature(activeCreatureId); + sidePanel.updateCreature(activeCreatureId); } - }, [activeCreatureId, sidePanel.panelView.mode, sidePanel.showCreature]); + }, [activeCreatureId, sidePanel.panelView.mode, sidePanel.updateCreature]); // Auto-scroll to the active combatant when the turn changes const activeRowRef = useRef(null); diff --git a/apps/web/src/hooks/use-side-panel-state.ts b/apps/web/src/hooks/use-side-panel-state.ts index 21a5a2e..825ac28 100644 --- a/apps/web/src/hooks/use-side-panel-state.ts +++ b/apps/web/src/hooks/use-side-panel-state.ts @@ -19,6 +19,7 @@ interface SidePanelState { interface SidePanelActions { showCreature: (creatureId: CreatureId) => void; + updateCreature: (creatureId: CreatureId) => void; showBulkImport: () => void; showSourceManager: () => void; dismissPanel: () => void; @@ -52,6 +53,10 @@ export function useSidePanelState(): SidePanelState & SidePanelActions { setIsRightPanelCollapsed(false); }, []); + const updateCreature = useCallback((creatureId: CreatureId) => { + setPanelView({ mode: "creature", creatureId }); + }, []); + const showBulkImport = useCallback(() => { setPanelView({ mode: "bulk-import" }); setIsRightPanelCollapsed(false); @@ -91,6 +96,7 @@ export function useSidePanelState(): SidePanelState & SidePanelActions { pinnedCreatureId, isWideDesktop, showCreature, + updateCreature, showBulkImport, showSourceManager, dismissPanel,