From fefd377408c5bc65e362c4fbea58be4791869142 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Mon, 6 Mar 2023 15:27:02 +0530 Subject: [PATCH] fix coords when bound text height overflows during shift resize --- src/element/textElement.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/element/textElement.ts b/src/element/textElement.ts index 37562ca9e..cd27d5b34 100644 --- a/src/element/textElement.ts +++ b/src/element/textElement.ts @@ -191,7 +191,7 @@ export const handleBindTextResize = ( nextWidth = dimensions.width; } // increase height in case text element height exceeds - if (nextHeight > maxHeight) { + if (!shouldMaintainAspectRatio && nextHeight > maxHeight) { containerHeight = computeContainerHeightForBoundText( container, nextHeight, @@ -226,6 +226,16 @@ export const handleBindTextResize = ( textElement as ExcalidrawTextElementWithContainer, ), ); + if (shouldMaintainAspectRatio && nextHeight > maxHeight) { + containerHeight = computeContainerHeightForBoundText( + container, + nextHeight, + ); + mutateElement(container, { + y: textElement.y - BOUND_TEXT_PADDING, + height: containerHeight, + }); + } } } }; @@ -800,3 +810,9 @@ export const getMaxContainerHeight = (container: ExcalidrawElement) => { } return height - BOUND_TEXT_PADDING * 2; }; + +// export const computeContainerCoordsFromBoundText = ( +// boundText: ExcalidrawTextElementWithContainer, +// ) => { + +// };