From 83da487b24cf969d99cdba0ba292e406c93f0df6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 14 Apr 2026 20:16:49 +0000 Subject: [PATCH] :bug: Fix append-class producing leading space for empty class When called with an empty string as the base class, append-class was producing " bar" (with a leading space) because (some? "") returns true. Use (seq class) instead to treat both nil and empty string as absent, avoiding invalid CSS class strings with leading whitespace. --- common/src/app/common/data.cljc | 5 +++-- common/test/common_tests/data_test.cljc | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index 70f775b4c3..715bd97544 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -1156,5 +1156,6 @@ (defn append-class [class current-class] - (str (if (some? class) (str class " ") "") - current-class)) + (if (seq class) + (str class " " current-class) + current-class)) diff --git a/common/test/common_tests/data_test.cljc b/common/test/common_tests/data_test.cljc index f0487ed71d..d85e835af9 100644 --- a/common/test/common_tests/data_test.cljc +++ b/common/test/common_tests/data_test.cljc @@ -791,7 +791,8 @@ (t/deftest append-class-test (t/is (= "foo bar" (d/append-class "foo" "bar"))) (t/is (= "bar" (d/append-class nil "bar"))) - (t/is (= " bar" (d/append-class "" "bar")))) + ;; empty string is treated like nil — no leading space + (t/is (= "bar" (d/append-class "" "bar")))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Additional helpers (5th batch)