Skip to content

Commit dfac73f

Browse files
fix(ui): disable color picker while middle-mouse panning canvas
1 parent f4219d5 commit dfac73f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

invokeai/frontend/web/src/features/controlLayers/konva/CanvasTool/CanvasColorPickerToolModule.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ export class CanvasColorPickerToolModule extends CanvasModuleBase {
289289
this.manager.stage.setCursor('none');
290290
};
291291

292+
getCanPick = () => {
293+
if (this.manager.stage.getIsDragging()) {
294+
return false;
295+
}
296+
297+
return true;
298+
};
299+
292300
/**
293301
* Renders the color picker tool preview on the canvas.
294302
*/
@@ -298,6 +306,11 @@ export class CanvasColorPickerToolModule extends CanvasModuleBase {
298306
return;
299307
}
300308

309+
if (!this.getCanPick()) {
310+
this.setVisibility(false);
311+
return;
312+
}
313+
301314
const cursorPos = this.parent.$cursorPos.get();
302315

303316
if (!cursorPos) {
@@ -406,11 +419,21 @@ export class CanvasColorPickerToolModule extends CanvasModuleBase {
406419
};
407420

408421
onStagePointerUp = (_e: KonvaEventObject<PointerEvent>) => {
422+
if (!this.getCanPick()) {
423+
this.setVisibility(false);
424+
return;
425+
}
426+
409427
const { a: _, ...color } = this.$colorUnderCursor.get();
410428
this.manager.stateApi.setColor(color);
411429
};
412430

413431
onStagePointerMove = (_e: KonvaEventObject<PointerEvent>) => {
432+
if (!this.getCanPick()) {
433+
this.setVisibility(false);
434+
return;
435+
}
436+
414437
this.syncColorUnderCursor();
415438
};
416439

invokeai/frontend/web/src/features/controlLayers/konva/CanvasTool/CanvasToolModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class CanvasToolModule extends CanvasModuleBase {
164164
const selectedEntityAdapter = this.manager.stateApi.getSelectedEntityAdapter();
165165

166166
if (this.manager.stage.getIsDragging()) {
167-
this.tools.view.syncCursorStyle();
167+
stage.setCursor('grabbing');
168168
} else if (tool === 'view') {
169169
this.tools.view.syncCursorStyle();
170170
} else if (segmentingAdapter) {

0 commit comments

Comments
 (0)