Skip to content

Commit

Permalink
Disable port creation tool when clicking outside of a node
Browse files Browse the repository at this point in the history
  • Loading branch information
hlxid committed Oct 27, 2023
1 parent 6b4a52b commit 3287bdf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/features/toolPalette/portCreationTool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { injectable } from "inversify";
import { SChildElementImpl, SModelElementImpl, SPortImpl, SShapeElementImpl } from "sprotty";
import { CommitModelAction, SChildElementImpl, SModelElementImpl, SPortImpl, SShapeElementImpl } from "sprotty";
import { Action, SPort } from "sprotty-protocol";
import { generateRandomSprottyId } from "../../utils";
import { CreationTool } from "./creationTool";
Expand Down Expand Up @@ -54,7 +54,13 @@ export class PortCreationTool extends CreationTool<SPort, SPortImpl> {
}

mouseDown(target: SModelElementImpl, event: MouseEvent): Action[] {
// TODO: cancel addition of port if not inside a node right now
if (this.element?.parent === target.root) {
this.disable();
// Run some action to re-render the tool palette ui
// showing that the tool is disabled
return [CommitModelAction.create()];
}

return super.mouseDown(target, event);
}

Expand Down

0 comments on commit 3287bdf

Please sign in to comment.