Skip to content

Pan not working over selecting imports#38

Merged
MarkJB merged 1 commit intomainfrom
fix/pan-canvas-blocked-by-imports
Apr 11, 2026
Merged

Pan not working over selecting imports#38
MarkJB merged 1 commit intomainfrom
fix/pan-canvas-blocked-by-imports

Conversation

@MarkJB
Copy link
Copy Markdown
Member

@MarkJB MarkJB commented Apr 10, 2026

This pull request improves mouse interaction handling on the canvas by making right-click (mouse button 2) consistently initiate panning, in addition to the existing middle-click (button 1) support. It also ensures that only primary mouse button interactions trigger object manipulation (drag, scale, rotate, group bounding box handles), preventing accidental gestures with right or middle clicks. The tests are updated to cover these behaviors.

Mouse interaction and event handling improvements:

  • Updated useCanvasInteractionHandlers to allow both right-click (button 2) and middle-click (button 1) to start panning the canvas, and to prevent default browser behavior for these buttons.
  • Added a shared isNonPrimaryButton utility in several hooks (useObjectDrag, useObjectScaleRotate, useGroupOBB) to ensure that only primary button (button 0, usually left-click) can trigger object drag, scale, rotate, or group bounding box handle actions. [1] [2] [3] [4] [5] [6] [7]

Testing enhancements:

  • Added and improved tests in PlotCanvas.test.tsx to verify that right-click can pan the canvas, and that right-clicking on an import pans the canvas without moving the import itself. Also, refactored the ResizeObserver setup utility for reuse and removed duplicate code. [1] [2] [3]

@MarkJB
Copy link
Copy Markdown
Member Author

MarkJB commented Apr 10, 2026

Relates to issue #36

@MarkJB MarkJB merged commit 4ba264a into main Apr 11, 2026
4 checks passed
@MarkJB MarkJB deleted the fix/pan-canvas-blocked-by-imports branch April 11, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant