Virtual whiteboard for sketching hand-drawn like diagrams
fix: don't select binded text when ungrouping (#4470)
Aakansha Doshi1fd347cade5b
diff --git a/src/actions/actionGroup.tsx b/src/actions/actionGroup.tsxindex 92de75d7f4..af680ac9d4 100644--- a/src/actions/actionGroup.tsx+++ b/src/actions/actionGroup.tsx@@ -17,8 +17,9 @@ import {import { getNonDeletedElements } from "../element";import { randomId } from "../random";import { ToolButton } from "../components/ToolButton";-import { ExcalidrawElement } from "../element/types";+import { ExcalidrawElement, ExcalidrawTextElement } from "../element/types";import { AppState } from "../types";+import { isBoundToContainer } from "../element/typeChecks";const allElementsInSameGroup = (elements: readonly ExcalidrawElement[]) => {if (elements.length >= 2) {@@ -151,7 +152,12 @@ export const actionUngroup = register({if (groupIds.length === 0) {return { appState, elements, commitToHistory: false };}++ const boundTextElementIds: ExcalidrawTextElement["id"][] = [];const nextElements = elements.map((element) => {+ if (isBoundToContainer(element)) {+ boundTextElementIds.push(element.id);+ }const nextGroupIds = removeFromSelectedGroups(element.groupIds,appState.selectedGroupIds,@@ -163,11 +169,19 @@ export const actionUngroup = register({groupIds: nextGroupIds,});});++ const updateAppState = selectGroupsForSelectedElements(+ { ...appState, selectedGroupIds: {} },+ getNonDeletedElements(nextElements),+ );++ // remove binded text elements from selection+ boundTextElementIds.forEach(+ (id) => (updateAppState.selectedElementIds[id] = false),+ );return {- appState: selectGroupsForSelectedElements(- { ...appState, selectedGroupIds: {} },- getNonDeletedElements(nextElements),- ),+ appState: updateAppState,+elements: nextElements,commitToHistory: true,};