[Medium] [Bug] Crafting tab resets to Fabricator sub-tab when navigating away and back #340
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug: Crafting tab does not preserve active sub-tab when navigating away and back
Steps to reproduce
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(orCraftingTab.tsxcomponent state)Starting work. Investigating why the Crafting tab resets to Fabricator sub-tab when navigating away and back.
Fix complete.
Root cause:
CraftingTab.tsxused localuseState('fabricator')foractiveSubTab. When navigating away from the Crafting tab, the component unmounts and remounts, losing the selected sub-tab and resetting to'fabricator'.Fix: Moved
activeCraftingSubTabstate into the persisteduseCraftingStore(zustand + localStorage), so the selected sub-tab survives component remounts and page sessions.Changes:
craftingStore.types.ts— AddedCraftingAttunementtype andactiveCraftingSubTab+setActiveCraftingSubTabto state/actions interfacescraftingStore.ts— Added the action + includedactiveCraftingSubTabinpartializefor localStorage persistencecrafting-initial-state.ts— Default value'fabricator'CraftingTab.tsx— UsesuseCraftingStoreselectors instead of localuseStatestores/index.ts— Re-exportsCraftingStoreandCraftingAttunementtypesFiles changed: 7 files, 15 insertions, 7 deletions. All 1105 tests pass.