Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: erase all elements which are hit with single point click #4934

Merged
merged 1 commit into from Mar 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/components/App.tsx
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