Repository: excalidraw/excalidraw
File: src/element/dragElements.ts (TypeScript)

Code before:
  pointerY: number,
  lockDirection: boolean = false,
  distanceX: number = 0,
  distanceY: number = 0,
  appState: AppState,
) => {
  const [x1, y1] = getCommonBounds(selectedElements);
  const offset = { x: pointerX - x1, y: pointerY - y1 };
  selectedElements.forEach((element) => {
    updateElementCoords(
      lockDirection,
      distanceX,
      distanceY,
      pointerDownState,
      element,
      offset,
    );
    // update coords of bounded text only when element doesn't belong
    // to any group or element in a group / nested group is selected
    if (
      !element.groupIds.length ||
      // Note: editingGroupId is set whenever editing elements
      // or nested group but isSelectedViaGroup is true only
      // when a group is selected so we need avoid updating coords
      // when nested group is selected
      (appState.editingGroupId && !isSelectedViaGroup(appState, element))
    ) {
      const boundTextElementId = getBoundTextElementId(element);
      if (boundTextElementId) {
        const textElement =
          Scene.getScene(element)!.getElement(boundTextElementId);
        updateElementCoords(
          lockDirection,
          distanceX,
          distanceY,
          pointerDownState,
          textElement!,
          offset,
        );
      }
    }
    updateBoundElements(element, {
      simultaneouslyUpdated: selectedElements,
    });
  });
};

const updateElementCoords = (
  lockDirection: boolean,
  distanceX: number,
  distanceY: number,

Review comment (suggestion):
```suggestion
    // 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))
```

👍, a few nits around the comments

Code after:
  pointerY: number,
  lockDirection: boolean = false,
  distanceX: number = 0,
  distanceY: number = 0,
  appState: AppState,
) => {
  const [x1, y1] = getCommonBounds(selectedElements);
  const offset = { x: pointerX - x1, y: pointerY - y1 };
  selectedElements.forEach((element) => {
    updateElementCoords(
      lockDirection,
      distanceX,
      distanceY,
      pointerDownState,
      element,
      offset,
    );
    // 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 =
          Scene.getScene(element)!.getElement(boundTextElementId);
        updateElementCoords(
          lockDirection,
          distanceX,
          distanceY,
          pointerDownState,
          textElement!,
          offset,
        );
      }
    }
    updateBoundElements(element, {
      simultaneouslyUpdated: selectedElements,
    });
  });
};

const updateElementCoords = (
  lockDirection: boolean,
  distanceX: number,
  distanceY: number,
  pointerDownState: PointerDownState,