diff --git a/src/components/App.tsx b/src/components/App.tsx index 010fe929..27a6041b 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -3574,6 +3574,7 @@ class App extends React.Component { lockDirection, dragDistanceX, dragDistanceY, + this.state, ); this.maybeSuggestBindingForAll(selectedElements); diff --git a/src/element/dragElements.ts b/src/element/dragElements.ts index bf4c851f..f2133b8d 100644 --- a/src/element/dragElements.ts +++ b/src/element/dragElements.ts @@ -5,8 +5,9 @@ import { mutateElement } from "./mutateElement"; import { getPerfectElementSize } from "./sizeHelpers"; import Scene from "../scene/Scene"; import { NonDeletedExcalidrawElement } from "./types"; -import { PointerDownState } from "../types"; +import { AppState, PointerDownState } from "../types"; import { getBoundTextElementId } from "./textElement"; +import { isSelectedViaGroup } from "../groups"; export const dragSelectedElements = ( pointerDownState: PointerDownState, @@ -16,6 +17,7 @@ export const dragSelectedElements = ( lockDirection: boolean = false, distanceX: number = 0, distanceY: number = 0, + appState: AppState, ) => { const [x1, y1] = getCommonBounds(selectedElements); const offset = { x: pointerX - x1, y: pointerY - y1 }; @@ -28,7 +30,15 @@ export const dragSelectedElements = ( element, offset, ); - if (!element.groupIds.length) { + // update coords of bound text only if we're dragging the container directly + // (we don't drag the group that it's part of) + if ( + // container isn't part of any group + // (perf optim so we don't check `isSelectedViaGroup()` in every case) + !element.groupIds.length || + // container is part of a group, but we're dragging the container directly + (appState.editingGroupId && !isSelectedViaGroup(appState, element)) + ) { const boundTextElementId = getBoundTextElementId(element); if (boundTextElementId) { const textElement =