From 1bb056cbdbe6d9db98fdedb08693855a1b89dfcc Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 11 Sep 2020 12:44:07 +0200 Subject: [PATCH] :bug: Fixes add fill to text shapes --- .../ui/workspace/sidebar/options/fill.cljs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs index eae18ec17f..6f1ce8a575 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs @@ -42,8 +42,9 @@ [{:keys [ids type values editor] :as props}] (let [locale (mf/deref i18n/locale) shapes (deref (refs/objects-by-id ids)) - text-ids (map :id (filter #(= (:type %) :text) shapes)) - other-ids (map :id (filter #(not= (:type %) :text) shapes)) + is-text? #(= (:type %) :text) + text-ids (map :id (filter is-text? shapes)) + other-ids (map :id (filter (comp not is-text?) shapes)) show? (not (nil? (:fill-color values))) label (case type @@ -60,14 +61,29 @@ (mf/use-callback (mf/deps ids) (fn [event] - (st/emit! (dwc/update-shapes ids #(assoc % :fill-color cp/default-color))))) + (when-not (empty? other-ids) + (st/emit! (dwc/update-shapes other-ids #(assoc % :fill-color cp/default-color)))) + (when-not (empty? text-ids) + (run! #(st/emit! (dwt/update-text-attrs + {:id % + :editor editor + :attrs {:fill cp/default-color}})) + text-ids)))) on-delete (mf/use-callback (mf/deps ids) (fn [event] - (st/emit! (dwc/update-shapes ids #(dissoc % :fill-color))))) + (when-not (empty? other-ids) + (st/emit! (dwc/update-shapes other-ids #(dissoc % :fill-color)))) + + (when-not (empty? text-ids) + (run! #(st/emit! (dwt/update-text-attrs + {:id % + :editor editor + :attrs {:fill nil}})) + text-ids)))) on-change (mf/use-callback