From 4f7603a0a41be9069e51049a29bcf8bb8f14b148 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 14 Sep 2020 11:27:31 +0200 Subject: [PATCH] :sparkles: Improved colorpicker handling --- frontend/src/app/main/ui/workspace/colorpalette.cljs | 5 +++-- frontend/src/app/main/ui/workspace/viewport.cljs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/colorpalette.cljs b/frontend/src/app/main/ui/workspace/colorpalette.cljs index 89728ae61..a747a3d55 100644 --- a/frontend/src/app/main/ui/workspace/colorpalette.cljs +++ b/frontend/src/app/main/ui/workspace/colorpalette.cljs @@ -131,10 +131,11 @@ [:& dropdown {:show (:show-menu @state) :on-close #(swap! state assoc :show-menu false)} [:ul.workspace-context-menu.palette-menu - (for [cur-library (vals shared-libs)] + (for [[idx cur-library] (map-indexed vector (vals shared-libs))] (let [colors (-> cur-library (get-in [:data :colors]) vals)] [:li.palette-library - {:on-click #(st/emit! (mdc/change-palette-selected (:id cur-library)))} + {:key (str "library-" idx) + :on-click #(st/emit! (mdc/change-palette-selected (:id cur-library)))} (when (= selected (:id cur-library)) i/tick) [:div.library-name (str (:name cur-library) " " (str/format "(%s)" (count colors)))] [:div.color-sample diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 60fee17c8..c3c340d20 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -220,14 +220,14 @@ (st/emit! (dwc/stop-picker)) (modal/disallow-click-outside!))] - (mf/use-layout-effect + (mf/use-effect ;; Everytime we finish retrieving a new URL we redraw the canvas ;; so even if we're not finished the user can start to pick basic ;; shapes (mf/deps props fetch-pending) (fn [] (try - (timers/schedule 100 + (timers/schedule #(let [svg-node (mf/ref-val svg-ref) canvas-node (mf/ref-val canvas-ref) canvas-context (.getContext canvas-node "2d")