Skip to content

Commit f7d372c

Browse files
fix(ui): prevent bbox from following cursor after middle mouse pan
Added button checks to bbox rect and transformer mousedown/touchstart handlers to only process left clicks. Also added stage dragging check in onBboxDragMove to clear bbox drag state when middle mouse panning is active. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 5039bbe commit f7d372c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

invokeai/frontend/web/src/features/controlLayers/konva/CanvasSegmentAnythingModule.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ export class CanvasSegmentAnythingModule extends CanvasModuleBase {
437437

438438
// Handle manual drag detection for bbox rect
439439
this.konva.bboxRect.on('mousedown touchstart', (e) => {
440+
// Only handle left mouse button (0) or touch events
441+
// For mouse events, evt.button exists; for touch events, it doesn't
442+
if ('button' in e.evt && e.evt.button !== 0) {
443+
return;
444+
}
445+
440446
const data = this.$inputData.get();
441447
if (data.type !== 'visual') {
442448
return;
@@ -459,6 +465,11 @@ export class CanvasSegmentAnythingModule extends CanvasModuleBase {
459465

460466
// Handle transformer interactions
461467
this.konva.bboxTransformer.on('mousedown touchstart', (e) => {
468+
// Only handle left mouse button (0) or touch events
469+
if ('button' in e.evt && e.evt.button !== 0) {
470+
return;
471+
}
472+
462473
// Transformer handles its own dragging, just stop propagation
463474
e.cancelBubble = true;
464475
});
@@ -841,6 +852,13 @@ export class CanvasSegmentAnythingModule extends CanvasModuleBase {
841852
return;
842853
}
843854

855+
// If the stage is being dragged (e.g., with middle mouse), clear our bbox drag state
856+
if (this.manager.stage.getIsDragging()) {
857+
this.$bboxDragStart.set(null);
858+
this.$isBboxDragging.set(false);
859+
return;
860+
}
861+
844862
// If we're already dragging, no need to check again
845863
if (this.$isBboxDragging.get()) {
846864
return;

0 commit comments

Comments
 (0)