1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2025-02-18 13:29:36 +01:00

fix: translating frames containing grouped text containers (#7557)

This commit is contained in:
David Luzar 2024-01-13 21:28:54 +01:00 committed by GitHub
parent 41cc746885
commit 0fa5f5de4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,14 +5,9 @@ import { getPerfectElementSize } from "./sizeHelpers";
import { NonDeletedExcalidrawElement } from "./types"; import { NonDeletedExcalidrawElement } from "./types";
import { AppState, PointerDownState } from "../types"; import { AppState, PointerDownState } from "../types";
import { getBoundTextElement } from "./textElement"; import { getBoundTextElement } from "./textElement";
import { isSelectedViaGroup } from "../groups";
import { getGridPoint } from "../math"; import { getGridPoint } from "../math";
import Scene from "../scene/Scene"; import Scene from "../scene/Scene";
import { import { isArrowElement, isFrameLikeElement } from "./typeChecks";
isArrowElement,
isBoundToContainer,
isFrameLikeElement,
} from "./typeChecks";
export const dragSelectedElements = ( export const dragSelectedElements = (
pointerDownState: PointerDownState, pointerDownState: PointerDownState,
@ -37,13 +32,11 @@ export const dragSelectedElements = (
.map((f) => f.id); .map((f) => f.id);
if (frames.length > 0) { if (frames.length > 0) {
const elementsInFrames = scene for (const element of scene.getNonDeletedElements()) {
.getNonDeletedElements() if (element.frameId !== null && frames.includes(element.frameId)) {
.filter((e) => !isBoundToContainer(e)) elementsToUpdate.add(element);
.filter((e) => e.frameId !== null) }
.filter((e) => frames.includes(e.frameId!)); }
elementsInFrames.forEach((element) => elementsToUpdate.add(element));
} }
const commonBounds = getCommonBounds( const commonBounds = getCommonBounds(
@ -60,16 +53,9 @@ export const dragSelectedElements = (
elementsToUpdate.forEach((element) => { elementsToUpdate.forEach((element) => {
updateElementCoords(pointerDownState, element, adjustedOffset); updateElementCoords(pointerDownState, element, adjustedOffset);
// 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 ( if (
// Don't update coords of arrow label since we calculate its position during render // skip arrow labels since we calculate its position during render
!isArrowElement(element) && !isArrowElement(element)
// 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 textElement = getBoundTextElement(element); const textElement = getBoundTextElement(element);
if (textElement) { if (textElement) {