Skip to content

Commit

Permalink
Fixes #128
Browse files Browse the repository at this point in the history
deselects selected nodes
even if the clicked element has no selectFeature enabled

Signed-off-by: Jan Bicker <jan.bicker@typefox.io>
  • Loading branch information
jbicker committed Nov 8, 2023
1 parent 771285d commit 1b4d37a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/sprotty/src/features/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ export class SelectMouseListener extends MouseListener {

wasSelected = false;
hasDragged = false;
isMouseDown = false;

override mouseDown(target: SModelElementImpl, event: MouseEvent): (Action | Promise<Action>)[] {
if (event.button !== 0) {
return [];
}
this.isMouseDown = true;
const buttonHandled = this.handleButton(target, event);
if (buttonHandled) {
return buttonHandled;
Expand Down Expand Up @@ -217,7 +219,7 @@ export class SelectMouseListener extends MouseListener {
}

override mouseMove(target: SModelElementImpl, event: MouseEvent): Action[] {
this.hasDragged = true;
this.hasDragged = this.isMouseDown;
return [];
}

Expand All @@ -227,14 +229,15 @@ export class SelectMouseListener extends MouseListener {
const selectableTarget = findParentByFeature(target, isSelectable);
if (selectableTarget !== undefined) {
if (this.wasSelected) {
return [SelectAction.create({selectedElementsIDs:[selectableTarget.id],deselectedElementsIDs:[]})];
return [SelectAction.create({ selectedElementsIDs: [selectableTarget.id], deselectedElementsIDs: [] })];
}
} else if (target instanceof SModelRootImpl && !findViewportScrollbar(event)) {
// Mouse up on root but not over ViewPort's scroll bars > deselect all
} else if ((target instanceof SModelRootImpl && !findViewportScrollbar(event)) || !(target instanceof SModelRootImpl)) {
// Mouse up on everything that's not root or root but not over ViewPort's scroll bars > deselect all
return this.handleDeselectAll(this.collectElementsToDeselect(target, undefined), event);
}
}
}
this.isMouseDown = false;
this.hasDragged = false;
return [];
}
Expand Down

0 comments on commit 1b4d37a

Please sign in to comment.