mirror of
https://github.com/penpot/penpot.git
synced 2025-01-26 16:39:49 -05:00
🐛 Fix problem with center vertical align and auto-height
This commit is contained in:
parent
92d7521ec7
commit
abdc9b2cbd
2 changed files with 23 additions and 2 deletions
|
@ -392,4 +392,4 @@
|
||||||
(l/derived :workspace-text-modifier st/state))
|
(l/derived :workspace-text-modifier st/state))
|
||||||
|
|
||||||
(defn workspace-text-modifier-by-id [id]
|
(defn workspace-text-modifier-by-id [id]
|
||||||
(l/derived #(get % id) workspace-text-modifier))
|
(l/derived #(get % id) workspace-text-modifier =))
|
||||||
|
|
|
@ -87,7 +87,8 @@
|
||||||
(st/emit! (dwt/update-text-modifier id props))))
|
(st/emit! (dwt/update-text-modifier id props))))
|
||||||
|
|
||||||
(mf/defc text-container
|
(mf/defc text-container
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false
|
||||||
|
::mf/wrap [mf/memo]}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (obj/get props "shape")
|
(let [shape (obj/get props "shape")
|
||||||
on-update (obj/get props "on-update")
|
on-update (obj/get props "on-update")
|
||||||
|
@ -98,6 +99,7 @@
|
||||||
(fn [node]
|
(fn [node]
|
||||||
(when (some? node)
|
(when (some? node)
|
||||||
(on-update shape node))))]
|
(on-update shape node))))]
|
||||||
|
|
||||||
[:& fo/text-shape {:key (str "shape-" (:id shape))
|
[:& fo/text-shape {:key (str "shape-" (:id shape))
|
||||||
:ref handle-update
|
:ref handle-update
|
||||||
:shape shape
|
:shape shape
|
||||||
|
@ -144,10 +146,29 @@
|
||||||
(-> (mf/deref refs/workspace-editor-state)
|
(-> (mf/deref refs/workspace-editor-state)
|
||||||
(get (:id shape)))
|
(get (:id shape)))
|
||||||
|
|
||||||
|
text-modifier-ref
|
||||||
|
(mf/use-memo (mf/deps (:id shape)) #(refs/workspace-text-modifier-by-id (:id shape)))
|
||||||
|
|
||||||
|
text-modifier
|
||||||
|
(mf/deref text-modifier-ref)
|
||||||
|
|
||||||
shape (cond-> shape
|
shape (cond-> shape
|
||||||
(some? editor-state)
|
(some? editor-state)
|
||||||
(update-with-editor-state 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
|
||||||
|
;; 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)))))
|
||||||
|
|
||||||
|
shape (hooks/use-equal-memo shape)
|
||||||
|
|
||||||
handle-update-shape (mf/use-callback update-text-modifier)]
|
handle-update-shape (mf/use-callback update-text-modifier)]
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
|
|
Loading…
Add table
Reference in a new issue