Fix infoExitOnScroll feature by implementing proper state machine transitions #246
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
infoExitOnScrollfeature was not working correctly. When a user toggled gameInfo on and then scrolled, the info panel should automatically toggle off (as if the toggle key was pressed again), but it wasn't happening.Root Cause
The issue was in the state machine flow and timing of when
resetInfoToggle()was called:Bypassed State Machine: The
resetInfoToggle()function directly called exit methods (gameInfoExit(),collectionInfoExit(),buildInfoExit()) and immediately set boolean flags tofalse, bypassing the proper state machine transitions.Missing Animation Coordination: Manual toggle properly uses state machine transitions (
RETROFE_GAMEINFO_EXIT→ animation → flag reset), but scroll-triggered exit skipped this flow, causing timing and animation issues.Immediate Flag Reset: Boolean flags were reset immediately instead of being coordinated with the exit animation sequence.
Solution
This fix implements proper state machine transitions for scroll-triggered info exits:
Key Changes
1. Enhanced
resetInfoToggle()FunctionvoidtoRETROFE_STATERETROFE_GAMEINFO_EXIT,RETROFE_COLLECIONINFO_EXIT,RETROFE_BUILDINFO_EXIT)falsebefore returning exit state (matching manual toggle behavior)2. Added Pending State Management
pendingScrollState_member to store intended scroll direction3. Updated Scroll Input Handling
processUserInput()now checksresetInfoToggle()return value4. Enhanced State Machine
RETROFE_GAMEINFO_EXIT,RETROFE_COLLECIONINFO_EXIT,RETROFE_BUILDINFO_EXIT)Result
The
infoExitOnScrollfeature now works correctly:Testing
Created comprehensive unit tests verifying:
The fix ensures that when
infoExitOnScrollis enabled and the user scrolls while any info panel is active, the info panel smoothly exits before scrolling proceeds, matching the expected behavior described in the issue.This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.