From 3a85537c2fba6a95549d66e6a0801f6f76c650b1 Mon Sep 17 00:00:00 2001 From: dwelle <5153846+dwelle@users.noreply.github.com> Date: Wed, 16 Apr 2025 10:13:50 +0200 Subject: [PATCH] fix: erasing locked elements --- packages/excalidraw/eraser/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/excalidraw/eraser/index.ts b/packages/excalidraw/eraser/index.ts index a9f9103f5..eaae46b95 100644 --- a/packages/excalidraw/eraser/index.ts +++ b/packages/excalidraw/eraser/index.ts @@ -91,7 +91,11 @@ export class EraserTrail extends AnimatedTrail { // take only POINTS_ON_TRAIL points to form some number of segments eraserPath = eraserPath?.slice(eraserPath.length - POINTS_ON_TRAIL); - const visibleElementsMap = arrayToMap(this.app.visibleElements); + const candidateElements = this.app.visibleElements.filter( + (el) => !el.locked, + ); + + const visibleElementsMap = arrayToMap(candidateElements); const pathSegments = eraserPath.reduce((acc, point, index) => { if (index === 0) { @@ -105,7 +109,7 @@ export class EraserTrail extends AnimatedTrail { return []; } - for (const element of this.app.visibleElements) { + for (const element of candidateElements) { // restore only if already added to the to-be-erased set if (restoreToErase && this.elementsToErase.has(element.id)) { const intersects = eraserTest(