Restore Pokédex and Sets list position after detail navigation - #312
Conversation
# Conflicts: # frontend/src/pages/SetDetail.jsx
|
Thanks, @engelben, for the contribution. I kept your core sessionStorage and anchor-based restoration approach and added several follow-up improvements: • Preserved restoration state across repeated browser Back/Forward cycles instead of consuming it after the first return. I also completed final desktop, mobile, automated, and build validation. Everything relevant to this PR is now working as intended. Thanks again! |
Summary
Restore list state and scroll position when returning from Pokémon and set detail pages.
This updates the following navigation flows:
/pokedex→/pokedex/:dexId/sets→/sets/:setIdChanges
sessionStoragebefore opening a detail page./pokedexand/setsfallbacks for direct detail-page visits and refreshed detail pages.Implementation
A shared
useListScrollRestorationhook owns:Saved restoration requests are scoped by both list name and React Router location key. This prevents a stale Pokédex or Sets position from being applied during a fresh navigation to the list.
Restoration runs after the list reports that it is ready and after two animation frames, allowing asynchronously fetched content to render before applying the saved offset.
Manual test plan
Pokédex
/pokedex.Sets
/sets.Direct detail entry
/pokedexor/sets.