Merge pull request #9814 from penpot/hiru-fix-detach-token-typ

🐛 Fix changed font size when editing a text with no changes
This commit is contained in:
Aitor Moreno 2026-05-26 11:42:30 +02:00 committed by GitHub
commit eb095169b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View File

@ -8,6 +8,7 @@
(:require
[app.common.data :as d]
[app.common.types.text :as txt]
[app.util.dom :as dom]
[app.util.text.content.styles :as styles]))
(defn is-text-node
@ -60,7 +61,15 @@
(defn get-paragraph-styles
[element]
(get-attrs-from-styles element (d/concat-set txt/paragraph-attrs txt/text-node-attrs) (d/merge txt/default-paragraph-attrs txt/default-text-attrs)))
(let [styles (get-attrs-from-styles element
(d/concat-set txt/paragraph-attrs txt/text-node-attrs)
(d/merge txt/default-paragraph-attrs txt/default-text-attrs))
;; Recover real font-size from data attribute, which to_dom/get-paragraph-styles may have
;; changed to "0" ("0" trick to avoid it interfering with height calculation in the browser).
saved-font-size (dom/get-data element "saved-font-size")]
(cond-> styles
(some? saved-font-size)
(assoc :font-size saved-font-size))))
(defn get-root-styles
[element]

View File

@ -133,7 +133,11 @@
(create-element
"div"
{:id (or (:key paragraph) (create-random-key))
:data {:itype "paragraph"}
:data {:itype "paragraph"
;; Save the real font size to be restored later in from-dom/get-paragraph-styles,
;; because the function get-paragraph-styles here sets it to "0" in the css properties,
;; to avoid the browser affecting the height calculation.
:saved-font-size (:font-size paragraph)}
:style (get-paragraph-styles paragraph)}
(mapv #(create-text-span % paragraph) (:children paragraph))))