Implemented a comprehensive scroll position memory system for the game announcer tool's tabbed interface, allowing users to maintain their scroll position when navigating between tabs. Added a user preference toggle to enable/disable this feature.
- Created
useScrollPositioncustom hook to manage scroll position persistence - Scroll positions are stored in
sessionStorageand persist during the browser session - Pages with scroll memory:
- Schedule
- Teams
- Ranks
- Announce
- Play by Play
- Alliance Selection (when in Alliance Selection mode)
- Alliance Selection Brackets Mode: Always scrolls to top (no memory) when displaying brackets
- Alliance Selection Mode: Remembers scroll position to allow users to navigate to Rankings and return
- Match Navigation: When navigating to a different match on Announce or Play By Play pages, both pages reset their scroll positions to top
- Other Pages: All pages without scroll memory (Setup, Awards, Stats, Cheatsheet, Emcee) automatically scroll to top when navigated to
- Added "Enable screen scroll memory" toggle in Setup page under User Interface Settings
- Setting is persisted using
usePersistentStateand defaults to enabled - When disabled, all pages scroll to top regardless of previous scroll position
src/hooks/useScrollPosition.jsx: Custom hook for managing scroll position memory
src/pages/SchedulePage.jsx: Added scroll position memorysrc/pages/TeamDataPage.jsx: Added scroll position memorysrc/pages/RanksPage.jsx: Added scroll position memorysrc/pages/AnnouncePage.jsx: Added scroll position memory with match change reset logicsrc/pages/PlayByPlayPage.jsx: Added scroll position memory with match change reset logicsrc/pages/AllianceSelectionPage.jsx: Added conditional scroll memory (disabled in Brackets mode)src/pages/SetupPage.jsx: Added scroll memory toggle switchsrc/App.jsx:- Added
useScrollMemorystate management - Updated Layout component to scroll other pages to top
- Passed
useScrollMemoryprop to all relevant pages
- Added
src/hooks/UsePersistentState.jsx: Fixed bug wherefalsevalues were incorrectly treated as falsy, causing program selection to not persist on page reload
- Fixed
UsePersistentStatehook to properly handle falsy values (false,0, empty strings) by checking explicitly fornull/undefinedinstead of using||operator - This fix also resolved an issue where the selected program (FRC/FTC) was not persisting across page reloads
- Verify scroll positions are remembered when navigating between tabs
- Verify scroll resets when match changes on Announce/Play By Play pages
- Verify Alliance Selection Brackets mode always starts at top
- Verify Alliance Selection mode remembers scroll position
- Verify toggle in Settings properly enables/disables scroll memory
- Verify program selection persists across page reloads