[Medium] [Bug] Crafting tab resets to Fabricator sub-tab when navigating away and back #340

Closed
opened 2026-06-09 12:52:45 +02:00 by Anexim · 2 comments
Owner

Bug: Crafting tab does not preserve active sub-tab when navigating away and back

Steps to reproduce

  1. Open the game
  2. Go to Crafting tab
  3. Click "Enchanter" sub-tab
  4. Navigate to any other tab (e.g., Debug)
  5. Navigate back to Crafting tab

Expected

The Crafting tab should show the Enchanter sub-tab (the last active sub-tab).

Actual

The Crafting tab resets to the Fabricator sub-tab (the default). The state of which sub-tab was active is not preserved.

Root cause

The CraftingTab component uses local React state (useState) for the active sub-tab instead of persisting it to the store or localStorage. When the component unmounts (tab switch), the state is lost.

Store

useCraftingStore (or CraftingTab.tsx component state)

## Bug: Crafting tab does not preserve active sub-tab when navigating away and back ### Steps to reproduce 1. Open the game 2. Go to Crafting tab 3. Click "Enchanter" sub-tab 4. Navigate to any other tab (e.g., Debug) 5. Navigate back to Crafting tab ### Expected The Crafting tab should show the Enchanter sub-tab (the last active sub-tab). ### Actual The Crafting tab resets to the Fabricator sub-tab (the default). The state of which sub-tab was active is not preserved. ### Root cause The CraftingTab component uses local React state (`useState`) for the active sub-tab instead of persisting it to the store or localStorage. When the component unmounts (tab switch), the state is lost. ### Store `useCraftingStore` (or `CraftingTab.tsx` component state)
Anexim added the ai:todo label 2026-06-09 12:52:45 +02:00
n8n-gitea was assigned by Anexim 2026-06-09 12:52:45 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-09 19:03:26 +02:00
Author
Owner

Starting work. Investigating why the Crafting tab resets to Fabricator sub-tab when navigating away and back.

Starting work. Investigating why the Crafting tab resets to Fabricator sub-tab when navigating away and back.
Anexim added ai:done and removed ai:in-progress labels 2026-06-09 19:09:42 +02:00
Author
Owner

Fix complete.

Root cause: CraftingTab.tsx used local useState('fabricator') for activeSubTab. When navigating away from the Crafting tab, the component unmounts and remounts, losing the selected sub-tab and resetting to 'fabricator'.

Fix: Moved activeCraftingSubTab state into the persisted useCraftingStore (zustand + localStorage), so the selected sub-tab survives component remounts and page sessions.

Changes:

  • craftingStore.types.ts — Added CraftingAttunement type and activeCraftingSubTab + setActiveCraftingSubTab to state/actions interfaces
  • craftingStore.ts — Added the action + included activeCraftingSubTab in partialize for localStorage persistence
  • crafting-initial-state.ts — Default value 'fabricator'
  • CraftingTab.tsx — Uses useCraftingStore selectors instead of local useState
  • stores/index.ts — Re-exports CraftingStore and CraftingAttunement types

Files changed: 7 files, 15 insertions, 7 deletions. All 1105 tests pass.

**Fix complete.** **Root cause:** `CraftingTab.tsx` used local `useState('fabricator')` for `activeSubTab`. When navigating away from the Crafting tab, the component unmounts and remounts, losing the selected sub-tab and resetting to `'fabricator'`. **Fix:** Moved `activeCraftingSubTab` state into the persisted `useCraftingStore` (zustand + localStorage), so the selected sub-tab survives component remounts and page sessions. **Changes:** - `craftingStore.types.ts` — Added `CraftingAttunement` type and `activeCraftingSubTab` + `setActiveCraftingSubTab` to state/actions interfaces - `craftingStore.ts` — Added the action + included `activeCraftingSubTab` in `partialize` for localStorage persistence - `crafting-initial-state.ts` — Default value `'fabricator'` - `CraftingTab.tsx` — Uses `useCraftingStore` selectors instead of local `useState` - `stores/index.ts` — Re-exports `CraftingStore` and `CraftingAttunement` types **Files changed:** 7 files, 15 insertions, 7 deletions. All 1105 tests pass.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#340