mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix unknown original element for drag
This commit is contained in:
parent
b994753329
commit
d1b0aa63c4
2 changed files with 24 additions and 13 deletions
|
@ -8441,11 +8441,16 @@ class App extends React.Component<AppProps, AppState> {
|
|||
selectedElements.map((el) => [el.id, el]),
|
||||
),
|
||||
overrides: (el) => {
|
||||
const origEl = pointerDownState.originalElements.get(el.id)!;
|
||||
return {
|
||||
x: origEl.x,
|
||||
y: origEl.y,
|
||||
};
|
||||
const origEl = pointerDownState.originalElements.get(el.id);
|
||||
|
||||
if (origEl) {
|
||||
return {
|
||||
x: origEl.x,
|
||||
y: origEl.y,
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
},
|
||||
reverseOrder: true,
|
||||
});
|
||||
|
|
|
@ -183,7 +183,7 @@ export const duplicateElements = (
|
|||
};
|
||||
|
||||
// Helper to position cloned elements in the Z-order the product needs it
|
||||
const insertAfterIndex = (
|
||||
const insertBeforeOrAfterIndex = (
|
||||
index: number,
|
||||
elements: ExcalidrawElement | null | ExcalidrawElement[],
|
||||
) => {
|
||||
|
@ -249,7 +249,7 @@ export const duplicateElements = (
|
|||
return el.groupIds?.includes(groupId);
|
||||
});
|
||||
|
||||
insertAfterIndex(targetIndex, copyElements(groupElements));
|
||||
insertBeforeOrAfterIndex(targetIndex, copyElements(groupElements));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,10 @@ export const duplicateElements = (
|
|||
return el.frameId === frameId || el.id === frameId;
|
||||
});
|
||||
|
||||
insertAfterIndex(targetIndex, copyElements([...frameChildren, element]));
|
||||
insertBeforeOrAfterIndex(
|
||||
targetIndex,
|
||||
copyElements([...frameChildren, element]),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -287,12 +290,12 @@ export const duplicateElements = (
|
|||
});
|
||||
|
||||
if (boundTextElement) {
|
||||
insertAfterIndex(
|
||||
insertBeforeOrAfterIndex(
|
||||
targetIndex + (!!opts?.reverseOrder ? -1 : 0),
|
||||
copyElements([element, boundTextElement]),
|
||||
);
|
||||
} else {
|
||||
insertAfterIndex(targetIndex, copyElements(element));
|
||||
insertBeforeOrAfterIndex(targetIndex, copyElements(element));
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -306,9 +309,12 @@ export const duplicateElements = (
|
|||
});
|
||||
|
||||
if (container) {
|
||||
insertAfterIndex(targetIndex, copyElements([container, element]));
|
||||
insertBeforeOrAfterIndex(
|
||||
targetIndex,
|
||||
copyElements([container, element]),
|
||||
);
|
||||
} else {
|
||||
insertAfterIndex(targetIndex, copyElements(element));
|
||||
insertBeforeOrAfterIndex(targetIndex, copyElements(element));
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -317,7 +323,7 @@ export const duplicateElements = (
|
|||
// default duplication (regular elements)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
insertAfterIndex(
|
||||
insertBeforeOrAfterIndex(
|
||||
findLastIndex(elementsWithClones, (el) => el.id === element.id),
|
||||
copyElements(element),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue