From 57a700f82ede873a26569d3d4ca21e9fd2417e3a Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Thu, 27 Apr 2023 12:45:47 +0530 Subject: [PATCH] fix coords --- src/element/textElement.ts | 16 +++++++++------- src/element/textWysiwyg.tsx | 7 ++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/element/textElement.ts b/src/element/textElement.ts index fb145d169..e5c5d508e 100644 --- a/src/element/textElement.ts +++ b/src/element/textElement.ts @@ -98,13 +98,15 @@ export const redrawTextBoundingBox = ( mutateElement(container, { height: nextHeight }); updateOriginalContainerCache(container.id, nextHeight); } - const updatedTextElement = { - ...textElement, - ...boundTextUpdates, - } as ExcalidrawTextElementWithContainer; - const { x, y } = computeBoundTextPosition(container, updatedTextElement); - boundTextUpdates.x = x; - boundTextUpdates.y = y; + if (!isArrowElement(container)) { + const updatedTextElement = { + ...textElement, + ...boundTextUpdates, + } as ExcalidrawTextElementWithContainer; + const { x, y } = computeBoundTextPosition(container, updatedTextElement); + boundTextUpdates.x = x; + boundTextUpdates.y = y; + } } mutateElement(textElement, boundTextUpdates); diff --git a/src/element/textWysiwyg.tsx b/src/element/textWysiwyg.tsx index 63bc9e4a4..272434705 100644 --- a/src/element/textWysiwyg.tsx +++ b/src/element/textWysiwyg.tsx @@ -235,15 +235,12 @@ export const textWysiwyg = ({ } // Start pushing text upward until a diff of 30px (padding) // is reached - else { + else if (!isArrowElement(container)) { const containerCoords = getContainerCoords(container); // vertically center align the text if (verticalAlign === VERTICAL_ALIGN.MIDDLE) { - if (!isArrowElement(container)) { - coordY = - containerCoords.y + maxHeight / 2 - textElementHeight / 2; - } + coordY = containerCoords.y + maxHeight / 2 - textElementHeight / 2; } if (verticalAlign === VERTICAL_ALIGN.BOTTOM) { coordY = containerCoords.y + (maxHeight - textElementHeight);