From 0a529943a2402dd6d5e47fb39dde79d906ab2d19 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 18 Oct 2022 13:50:23 +0200 Subject: [PATCH] :bug: Fix text out of borders with "auto width" and center align --- CHANGES.md | 1 + .../workspace/shapes/text/viewport_texts_html.cljs | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d84fb47081..1043ac0dee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -61,6 +61,7 @@ - Fix notification to newsletter is shown in all cases [Taiga #4367](https://tree.taiga.io/project/penpot/issue/4367) - Fix comments section is not scrolling by mouse wheel [Taiga #4305](https://tree.taiga.io/project/penpot/issue/4305) - Fix justify alignes text left [Taiga #4322](https://tree.taiga.io/project/penpot/issue/4322) +- Fix text out of borders with "auto width" and center align [Taiga #4308](https://tree.taiga.io/project/penpot/issue/4308) ## 1.15.4-beta diff --git a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs index 00cd7303fc..e2992ea9ce 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs @@ -189,16 +189,12 @@ (some? editor-state) (update-with-editor-state editor-state)) - ;; When we have a text with grow-type :auto-height we need to check the correct height + ;; When we have a text with grow-type :auto-height or :auto-height we need to check the correct height ;; otherwise the center alignment will break - shape - (if (or (not= :auto-height (:grow-type shape)) (empty? text-modifier)) - shape - (let [tr-shape (dwt/apply-text-modifier shape text-modifier)] - (cond-> shape - ;; we only change the height otherwise could cause problems with the other fields - (some? text-modifier) - (assoc :height (:height tr-shape))))) + tr-shape (when text-modifier (dwt/apply-text-modifier shape text-modifier)) + shape (cond-> shape + (and (some? text-modifier) (#{:auto-height :auto-width} (:grow-type shape))) + (assoc :width (:width tr-shape) :height (:height tr-shape))) shape (hooks/use-equal-memo shape)