setting bbox visibility moved into render method

This commit is contained in:
Attila Cseh
2025-08-05 08:51:38 +02:00
committed by psychedelicious
parent 1e9e78089e
commit 04572c94ad

View File

@@ -198,7 +198,7 @@ export class CanvasBboxToolModule extends CanvasModuleBase {
this.subscriptions.add(this.manager.$isBusy.listen(this.render));
// Listen for stage changes to update the bbox's visibility
this.subscriptions.add(this.$isBboxHidden.listen((isHidden) => this.konva.group.visible(!isHidden)));
this.subscriptions.add(this.$isBboxHidden.listen(this.render));
}
// This is a noop. The cursor is changed when the cursor enters or leaves the bbox.
@@ -214,13 +214,15 @@ export class CanvasBboxToolModule extends CanvasModuleBase {
};
/**
* Renders the bbox. The bbox is only visible when the tool is set to 'bbox'.
* Renders the bbox.
*/
render = () => {
const tool = this.manager.tool.$tool.get();
const { x, y, width, height } = this.manager.stateApi.runSelector(selectBbox).rect;
this.konva.group.visible(!this.$isBboxHidden.get());
// We need to reach up to the preview layer to enable/disable listening so that the bbox can be interacted with.
// If the mangaer is busy, we disable listening so the bbox cannot be interacted with.
this.konva.group.listening(tool === 'bbox' && !this.manager.$isBusy.get());