diff --git a/packages/chili-ui/src/project/tree/tree.ts b/packages/chili-ui/src/project/tree/tree.ts index 91093d77..9ef8e28d 100644 --- a/packages/chili-ui/src/project/tree/tree.ts +++ b/packages/chili-ui/src/project/tree/tree.ts @@ -143,10 +143,7 @@ export class Tree extends Control { } private onClick = (event: MouseEvent) => { - if ( - this.document.visual.eventHandler instanceof SelectionHandler && - this.document.visual.eventHandler.shapeType !== ShapeType.Shape - ) { + if (!this.canSelect()) { return; } @@ -178,6 +175,13 @@ export class Tree extends Control { event.dataTransfer!.dropEffect = "move"; }; + private canSelect() { + return ( + this.document.visual.eventHandler instanceof SelectionHandler && + this.document.visual.eventHandler.shapeType === ShapeType.Shape + ); + } + private setLastClickItem(item: INode | undefined) { if (this.lastClicked !== undefined) { this.nodeMap.get(this.lastClicked)?.removeSelectedStyle(style.current); diff --git a/packages/chili/src/selection.ts b/packages/chili/src/selection.ts index 01d2d8b3..ad277ea9 100644 --- a/packages/chili/src/selection.ts +++ b/packages/chili/src/selection.ts @@ -117,7 +117,8 @@ export class Selection implements ISelection, IDisposable { this.removeSelectedPublish(this._selectedNodes, true); } - private publishSelection() { + private updateSelection() { + this.document.visual.viewer.update(); PubSub.default.pub("selectionChanged", this.document, this._selectedNodes, this._unselectedNodes); } @@ -135,7 +136,7 @@ export class Selection implements ISelection, IDisposable { } }); this._selectedNodes.push(...nodes); - if (publish) this.publishSelection(); + if (publish) this.updateSelection(); } private removeSelectedPublish(nodes: INode[], publish: boolean) { @@ -148,6 +149,6 @@ export class Selection implements ISelection, IDisposable { } this._selectedNodes = this._selectedNodes.filter((m) => !nodes.includes(m)); this._unselectedNodes = nodes; - if (publish) this.publishSelection(); + if (publish) this.updateSelection(); } } diff --git a/packages/chili/src/services/editorService.ts b/packages/chili/src/services/editorService.ts index 817203da..497fbaf0 100644 --- a/packages/chili/src/services/editorService.ts +++ b/packages/chili/src/services/editorService.ts @@ -40,7 +40,6 @@ export class EditorService implements IService { } else { document.visual.resetEventHandler(); } - document.visual.viewer.update(); }; private getEventHandler(