fix: containerizing text incorrectly updates arrow bindings (#6369)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Samyat Gautam 2023-03-18 11:00:28 -04:00 committed by GitHub
parent 7e330c8ee1
commit 0726911fa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 122 additions and 7 deletions

View file

@ -239,15 +239,23 @@ export const actionCreateContainerFromText = register({
linearElementIds.includes(ele.id),
) as ExcalidrawLinearElement[];
linearElements.forEach((ele) => {
let startBinding = null;
let endBinding = null;
if (ele.startBinding) {
startBinding = { ...ele.startBinding, elementId: container.id };
let startBinding = ele.startBinding;
let endBinding = ele.endBinding;
if (startBinding?.elementId === textElement.id) {
startBinding = {
...startBinding,
elementId: container.id,
};
}
if (ele.endBinding) {
endBinding = { ...ele.endBinding, elementId: container.id };
if (endBinding?.elementId === textElement.id) {
endBinding = { ...endBinding, elementId: container.id };
}
if (startBinding || endBinding) {
mutateElement(ele, { startBinding, endBinding });
}
mutateElement(ele, { startBinding, endBinding });
});
}