From b802859a53e90da3b50463822922080a23724186 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 13 Apr 2026 17:50:45 +0000 Subject: [PATCH] :bug: Exclude nil decoded values when reading text styles from v2 editor The v2 editor style-reading functions (get-styles-from-style-declaration and get-attrs-from-styles) decoded empty CSS variable values to nil for typography-ref-file and typography-ref-id, then unconditionally included them in the result map. These nils propagated into shape content and sidebar values, ultimately leaking into new text shapes created after detaching a typography. Skip entries whose decoded/resolved value is nil so the keys are simply absent instead of present-with-nil. --- frontend/src/app/util/text/content/from_dom.cljs | 7 +++++-- frontend/src/app/util/text/content/styles.cljs | 14 +++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/util/text/content/from_dom.cljs b/frontend/src/app/util/text/content/from_dom.cljs index dbc318cc08..7773a13fee 100644 --- a/frontend/src/app/util/text/content/from_dom.cljs +++ b/frontend/src/app/util/text/content/from_dom.cljs @@ -50,8 +50,11 @@ [_ style-decode] (get styles/mapping key)] (style-decode (.getPropertyValue style style-name))) (let [style-name (styles/get-style-name key)] - (styles/normalize-attr-value key (.getPropertyValue style style-name))))] - (assoc acc key (if (value-empty? value) (get defaults key) value)))) + (styles/normalize-attr-value key (.getPropertyValue style style-name)))) + resolved (if (value-empty? value) (get defaults key) value)] + (if (some? resolved) + (assoc acc key resolved) + acc))) {} attrs))) (defn get-text-span-styles diff --git a/frontend/src/app/util/text/content/styles.cljs b/frontend/src/app/util/text/content/styles.cljs index 0adc821d46..7dcb3f5d31 100644 --- a/frontend/src/app/util/text/content/styles.cljs +++ b/frontend/src/app/util/text/content/styles.cljs @@ -200,13 +200,17 @@ (if (contains? mapping k) (let [style-name (get-style-name-as-css-variable k) [_ style-decode] (get mapping k) - style-value (.getPropertyValue style-declaration style-name)] - (when (or (not removed-mixed) (not (contains? mixed-values style-value))) - (assoc acc k (style-decode style-value)))) + style-value (.getPropertyValue style-declaration style-name) + decoded (style-decode style-value)] + (if (and (some? decoded) + (or (not removed-mixed) (not (contains? mixed-values style-value)))) + (assoc acc k decoded) + acc)) (let [style-name (get-style-name k) style-value (normalize-attr-value k (.getPropertyValue style-declaration style-name))] - (when (or (not removed-mixed) (not (contains? mixed-values style-value))) - (assoc acc k style-value))))) {} txt/text-style-attrs)) + (if (or (not removed-mixed) (not (contains? mixed-values style-value))) + (assoc acc k style-value) + acc)))) {} txt/text-style-attrs)) (defn get-styles-from-event "Returns a ClojureScript object compatible with text nodes"