From e1ccde6533c603d56f9cbb2b684cf87f7b276f23 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 4 Dec 2020 13:25:41 +0100 Subject: [PATCH] :bug: Fixed problem with texts inside groups --- frontend/src/app/main/ui/hooks.cljs | 7 +++++++ frontend/src/app/main/ui/workspace/effects.cljs | 5 ++--- .../ui/workspace/sidebar/options/rows/color_row.cljs | 10 +++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/main/ui/hooks.cljs b/frontend/src/app/main/ui/hooks.cljs index ab9953317..ba72e96c7 100644 --- a/frontend/src/app/main/ui/hooks.cljs +++ b/frontend/src/app/main/ui/hooks.cljs @@ -214,3 +214,10 @@ (mf/use-effect (fn [] (let [sub (->> stream (rx/subs on-subscribe))] #(rx/dispose! sub))))) + +;; https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state +(defn use-previous [value] + (let [ref (mf/use-ref)] + (mf/use-effect + #(mf/set-ref-val! ref value)) + (mf/ref-val ref))) diff --git a/frontend/src/app/main/ui/workspace/effects.cljs b/frontend/src/app/main/ui/workspace/effects.cljs index ab94350a5..8937e7513 100644 --- a/frontend/src/app/main/ui/workspace/effects.cljs +++ b/frontend/src/app/main/ui/workspace/effects.cljs @@ -60,11 +60,10 @@ nil (= type :frame) - (if selected? + (when selected? (do (dom/stop-propagation event) - (st/emit! (dw/start-move-selected))) - (st/emit! (dw/deselect-all))) + (st/emit! (dw/start-move-selected)))) :else (do diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs index 45bb7e84d..c9fbbce61 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs @@ -20,6 +20,7 @@ [app.util.color :as uc] [app.main.refs :as refs] [app.main.data.modal :as modal] + [app.main.ui.hooks :as h] [app.main.ui.components.color-bullet :as cb] [app.main.ui.components.numeric-input :refer [numeric-input]])) @@ -120,12 +121,15 @@ disable-opacity handle-pick-color handle-open - handle-close)))] + handle-close))) + + prev-color (h/use-previous color)] (mf/use-effect - (mf/deps color) + (mf/deps color prev-color) (fn [] - (modal/update-props! :colorpicker {:data (parse-color color)}))) + (when (not= prev-color color) + (modal/update-props! :colorpicker {:data (parse-color color)})))) [:div.row-flex.color-data [:& cb/color-bullet {:color color