Repository navigation
fix: right-click cancels warship/boat selection instead of opening the menu - #4729
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesUnit deselection behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/InputHandler.test.ts`:
- Around line 1142-1151: Update the warship right-click test around rightClick()
and emittedTypes() to inspect the emitted UnitSelectionEvent payload, asserting
that unit is null and isSelected is false. Keep the existing assertions that a
deselection event is emitted and no ContextMenuEvent is emitted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8aba240b-da71-4a1c-87f8-747ac99c5fa4
📒 Files selected for processing (2)
src/client/InputHandler.tstests/InputHandler.test.ts
…e menu With a warship/boat selected, right-clicking opened the radial context menu instead of cancelling the selection: InputHandler.onContextMenu emitted ContextMenuEvent unconditionally, with no branch for an active selection, and the EventBus has no way for another listener to suppress the menu. Mirror the existing ghost-structure cancel in onContextMenu: track whether any unit is selected (InputHandler already listens to UnitSelectionEvent for the cursor) and, on right-click, cancel the selection and return before emitting ContextMenuEvent. Add regression tests covering both the selected (cancel, no menu) and unselected (menu opens) cases. Resolves openfrontio#4692 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e238ff9 to
b65c432
Compare
Address review feedback: verify the emitted UnitSelectionEvent is specifically a deselection (unit === null, isSelected === false) rather than just any UnitSelectionEvent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Good catch — updated the test to assert the emitted event is specifically a deselection ( |
|
@eastwoodgrant (via Discord): needs milestone |
Resolves #4692
Problem
With a warship/boat selected, right-clicking opened the radial context menu instead of cancelling the selection.
InputHandler.onContextMenuemittedContextMenuEventunconditionally — there was no branch for an active unit selection, and theEventBushas no way for another listener to suppress the menu.Fix
onContextMenualready cancels an in-progress action on right-click — if a ghost structure is being placed, it clears it and returns instead of opening the menu. This applies the same pattern to unit selection:InputHandleralready listens toUnitSelectionEvent(to set the cursor); it now also tracksunitSelectionActive(single or multi selection).onContextMenu, if a unit is selected, emit a deselect and return before emittingContextMenuEvent.Fully contained in
InputHandler.ts— no new shared state, no changes to the selection controller or renderer.Testing
tests/InputHandler.test.ts: right-click with a warship selected cancels the selection and does not open the menu; with nothing selected the menu still opens.npm test).Discord: granster9