From c9af72e2ee1a5e3b29006d577f3571ba6d73b755 Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Wed, 8 Nov 2023 15:48:36 +0800 Subject: [PATCH] fix: lock/unlock elements in frames --- src/actions/actionElementLock.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/actions/actionElementLock.ts b/src/actions/actionElementLock.ts index cd539c5a3..d24c6a6a9 100644 --- a/src/actions/actionElementLock.ts +++ b/src/actions/actionElementLock.ts @@ -10,17 +10,12 @@ const shouldLock = (elements: readonly ExcalidrawElement[]) => export const actionToggleElementLock = register({ name: "toggleElementLock", trackEvent: { category: "element" }, - predicate: (elements, appState, _, app) => { - const selectedElements = app.scene.getSelectedElements(appState); - return !selectedElements.some( - (element) => element.locked && element.frameId, - ); - }, perform: (elements, appState, _, app) => { + // Frames and their children should not be selected at the same time. + // Therefore, there's no need to include elements in frame in the selection. const selectedElements = app.scene.getSelectedElements({ selectedElementIds: appState.selectedElementIds, includeBoundTextElement: true, - includeElementsInFrames: true, }); if (!selectedElements.length) { @@ -31,7 +26,11 @@ export const actionToggleElementLock = register({ const selectedElementsMap = arrayToMap(selectedElements); return { elements: elements.map((element) => { - if (!selectedElementsMap.has(element.id)) { + if ( + !selectedElementsMap.has(element.id) && + element.frameId && + !selectedElementsMap.has(element.frameId) + ) { return element; }