Skip to content

Commit

Permalink
fix: erase all elements which are hit with single point click (excali…
Browse files Browse the repository at this point in the history
  • Loading branch information
ad1992 authored Mar 17, 2022
1 parent 8c0a041 commit ceb43ed
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4441,12 +4441,15 @@ class App extends React.Component<AppProps, AppState> {
},
this.state,
);
const hitElement = this.getElementAtPosition(
const hitElements = this.getElementsAtPosition(
scenePointer.x,
scenePointer.y,
);

pointerDownState.hit.element = hitElement;
hitElements.forEach(
(hitElement) =>
(pointerDownState.elementIdsToErase[hitElement.id] = true),
);
}
this.eraseElements(pointerDownState);
return;
Expand Down Expand Up @@ -4592,16 +4595,12 @@ class App extends React.Component<AppProps, AppState> {
}

private eraseElements = (pointerDownState: PointerDownState) => {
const hitElement = pointerDownState.hit.element;
const elements = this.scene.getElements().map((ele) => {
if (pointerDownState.elementIdsToErase[ele.id]) {
return newElementWith(ele, { isDeleted: true });
} else if (hitElement && ele.id === hitElement.id) {
return newElementWith(ele, { isDeleted: true });
} else if (
isBoundToContainer(ele) &&
(pointerDownState.elementIdsToErase[ele.containerId] ||
(hitElement && ele.containerId === hitElement.id))
pointerDownState.elementIdsToErase[ele.containerId]
) {
return newElementWith(ele, { isDeleted: true });
}
Expand Down

0 comments on commit ceb43ed

Please sign in to comment.