From ceb43ed8fb879254587eb8c57efacce91a3b2de6 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Thu, 17 Mar 2022 21:03:59 +0530 Subject: [PATCH] fix: erase all elements which are hit with single point click (#4934) --- src/components/App.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index c9c68593..85d199af 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -4441,12 +4441,15 @@ class App extends React.Component { }, 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; @@ -4592,16 +4595,12 @@ class App extends React.Component { } 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 }); }