Explorar el Código

keep only unique frames when ungrouping

Ryan Di hace 1 año
padre
commit
afed893419
Se han modificado 1 ficheros con 11 adiciones y 5 borrados
  1. 11 5
      src/actions/actionGroup.tsx

+ 11 - 5
src/actions/actionGroup.tsx

@@ -190,12 +190,18 @@ export const actionUngroup = register({
 
     let nextElements = [...elements];
 
+    const frameIds: {
+      [id: string]: true;
+    } = {};
     const selectedElements = app.scene.getSelectedElements(appState);
-    const frames = selectedElements
-      .filter((element) => element.frameId)
-      .map((element) =>
-        app.scene.getElement(element.frameId!),
-      ) as ExcalidrawFrameElement[];
+    for (const element of selectedElements) {
+      if (element.frameId) {
+        frameIds[element.frameId] = true;
+      }
+    }
+    const frames = Object.keys(frameIds)
+      .map((eid) => app.scene.getElement(eid))
+      .filter((element) => element != null) as ExcalidrawFrameElement[];
 
     const boundTextElementIds: ExcalidrawTextElement["id"][] = [];
     nextElements = nextElements.map((element) => {