Fix(ui) mouse event#30
Merged
Merged
Conversation
This change clears the pending build unit type when the user switches tabs in the control panel. Previously, if a user selected a unit to build and then switched to another tab (e.g., to check their economy), the build selection would persist. This could lead to accidental builds if the user later clicked on the map without realizing they were still in build mode. This commit introduces a new `_changeTab` method that is called when any tab is clicked. This method updates the active tab and clears the `pendingBuildUnitType` in the `uiState`, ensuring that the build selection is reset when the user changes context.
El-Magico777
added a commit
that referenced
this pull request
Sep 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description:
This pull request addresses two UI bugs that were impacting the user experience: #29
Sticky Map Dragging: Previously, if a user started dragging the map and their mouse cursor passed over the
PlayerInfoOverlay, the map would continue to drag even after the mouse button was released. This required an extra click to stop the map movement. This was caused by thepointerupevent not being correctly handled when the cursor was over a UI element.This has been fixed in
InputHandler.tsby ensuring that thepointerDownstate is always reset on anypointerupevent, regardless of the target element. This prevents the "sticky drag" behavior and makes the map dragging more reliable.Persistent Build Selection: When a user selected a unit to build (e.g., an Atom Bomb) and then switched to a different tab in the build menu (e.g., from "Attack" to "Buildings"), the unit would remain selected. This could lead to confusion and accidental builds, as the crosshair for the selected unit would still be active.
This has been resolved by introducing a new
_changeTabmethod inControlPanel2.ts. This method is now called whenever a tab is clicked, and it ensures thatpendingBuildUnitTypeis set tonull, effectively clearing the build selection. This makes the UI more intuitive and prevents unexpected behavior.Changes:
src/client/InputHandler.ts: Modified theonPointerUpmethod to always reset thepointerDownstate, fixing the sticky map dragging bug.src/client/graphics/layers/ControlPanel2.ts:_changeTabmethod to handle tab switching and clear the build selection.@clickhandlers for each tab to use the new_changeTabmethod.These changes improve the overall user experience by making the UI more predictable and less prone to errors.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
el_magico777