SSShooter / SSShooter/mind-elixir-core
mouseSelectionButton: 2 breaks panning and selection
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 415
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Since v5.11.2, mouseSelectionButton: 2 no longer works. On 5.11.0, this option made the left button move/pan the map and the right button drag a selection box. On 5.11.2+ neither gesture does anything.
To Reproduce
- Create a MindElixir instance with
mouseSelectionButton: 2andeditable: true. - Left-drag on an empty area of the canvas; the map does not pan.
- Right-drag on an empty area of the canvas; no selection box appears.
Expected behavior
Left button pans the map; right button draws a selection box (as in 5.11.0).
Additional context
mouseSelectionButton: 0 (the default) works as expected. The regression was likely introduced by the pointer state machine refactor in v5.11.2 (commit 04d8b9ee4f, "implement CanvasPointerDown state to coordinate canvas interaction and selection").
As a workaround we changed the canvas pointer-down branch in src/mouse.ts (https://github.com/SSShooter/mind-elixir-core/blob/master/src/mouse.ts#L220) to check e.mouseSelectionButton instead of a hardcoded left button, which restores the 5.11.0 behavior for us:
- if (mind.editable && target.className === 'map-container' && e.button === 0 && e.pointerType === 'mouse') {
+ if (mind.editable && target.className === 'map-container' && e.button === e.mouseSelectionButton && e.pointerType === 'mouse') {
mind.ptState = State.BoxSelect
return
There might be unknown side-effects as I'm not fully aware of the setup.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/mouse.ts around the canvas pointer-down branch at the linked location, then compare the pointer state machine refactor from commit 04d8b9ee4f with the reported workaround. Reproduce with mouseSelectionButton: 2 and editable: true; done means left-drag pans the map and right-drag draws a selection box without breaking the default setting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100