fix: horizontal text alignment for bound text when resizing (#5721)

* Update textElement.ts

* Add test

* don't use modifier keys when not needed

Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
zsviczian 2022-09-27 13:14:41 +02:00 committed by GitHub
parent 4cb6f09559
commit b477c2ad6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 113 additions and 41 deletions

View file

@ -174,7 +174,12 @@ export const handleBindTextResize = (
} else {
updatedY = element.y + element.height / 2 - nextHeight / 2;
}
const updatedX = element.x + element.width / 2 - nextWidth / 2;
const updatedX =
textElement.textAlign === TEXT_ALIGN.LEFT
? element.x + BOUND_TEXT_PADDING
: textElement.textAlign === TEXT_ALIGN.RIGHT
? element.x + element.width - nextWidth - BOUND_TEXT_PADDING
: element.x + element.width / 2 - nextWidth / 2;
mutateElement(textElement, {
text,
width: nextWidth,