From 2bb2d4ca59239a18a66024c346eac3ce1637afa5 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 13 Feb 2024 12:21:54 +0100 Subject: [PATCH 1/2] :bug: Fix problem with align-self default --- .../app/main/ui/components/radio_buttons.cljs | 30 +++++++++++-------- .../sidebar/options/menus/layout_item.cljs | 3 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/main/ui/components/radio_buttons.cljs b/frontend/src/app/main/ui/components/radio_buttons.cljs index 92563917a9..a4366ba2a9 100644 --- a/frontend/src/app/main/ui/components/radio_buttons.cljs +++ b/frontend/src/app/main/ui/components/radio_buttons.cljs @@ -17,9 +17,9 @@ (mf/create-context nil)) (mf/defc radio-button - {::mf/wrap-props false} + {::mf/props :obj} [props] - (let [context (mf/use-ctx context) + (let [context (mf/use-ctx context) icon (unchecked-get props "icon") id (unchecked-get props "id") value (unchecked-get props "value") @@ -27,7 +27,10 @@ title (unchecked-get props "title") unique-key (unchecked-get props "unique-key") icon-class (unchecked-get props "icon-class") - type (or (unchecked-get props "type") "radio") + type (or (unchecked-get props "type") + (if (unchecked-get context "allow-empty") + "checkbox" + "radio")) on-change (unchecked-get context "on-change") selected (unchecked-get context "selected") @@ -59,14 +62,15 @@ :checked checked?}]])) (mf/defc radio-buttons - {::mf/wrap-props false} + {::mf/props :obj} [props] - (let [children (unchecked-get props "children") - on-change (unchecked-get props "on-change") - selected (unchecked-get props "selected") - name (unchecked-get props "name") - class (unchecked-get props "class") - wide (unchecked-get props "wide") + (let [children (unchecked-get props "children") + on-change (unchecked-get props "on-change") + selected (unchecked-get props "selected") + name (unchecked-get props "name") + class (unchecked-get props "class") + wide (unchecked-get props "wide") + allow-empty? (unchecked-get props "allow-empty") encode-fn (d/nilv (unchecked-get props "encode-fn") identity) decode-fn (d/nilv (unchecked-get props "encode-fn") identity) @@ -87,7 +91,8 @@ (mf/deps on-change) (fn [event] (let [input-node (dom/get-target event) - value (dom/get-target-val event)] + value (dom/get-target-val event) + value (when (not= value selected) value)] (when (fn? on-change) (do (on-change (decode-fn value) event) (dom/blur! input-node)))))) @@ -98,7 +103,8 @@ :on-change on-change' :name name :encode-fn encode-fn - :decode-fn decode-fn})] + :decode-fn decode-fn + :allow-empty allow-empty?})] [:& (mf/provider context) {:value context-value} [:div {:class (dm/str class " " (stl/css :radio-btn-wrapper)) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs index 8ea0346d3b..6929eb5050 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs @@ -230,7 +230,8 @@ [{:keys [is-col? align-self on-change] :as props}] [:& radio-buttons {:selected (d/name align-self) :on-change on-change - :name "flex-align-self"} + :name "flex-align-self" + :allow-empty true} [:& radio-button {:value "start" :icon (get-layout-flex-icon :align-self :start is-col?) :title "Align self start" From 4ece2ba14890c7e0736350234e19375c838e9ce3 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 13 Feb 2024 12:22:05 +0100 Subject: [PATCH 2/2] :bug: Fix problem with calculated margins in flex layout --- common/src/app/common/geom/shapes/flex_layout/params.cljc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/geom/shapes/flex_layout/params.cljc b/common/src/app/common/geom/shapes/flex_layout/params.cljc index 7bd1ce855f..b1e15c70bd 100644 --- a/common/src/app/common/geom/shapes/flex_layout/params.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/params.cljc @@ -88,8 +88,8 @@ parent-selrect (:selrect parent) padding (when (and (not (nil? parent)) (> (count shapes) 0)) - {:p1 (min (- min-y (:y1 parent-selrect)) (- (:y2 parent-selrect) max-y)) - :p2 (min (- min-x (:x1 parent-selrect)) (- (:x2 parent-selrect) max-x))})] + {:p1 (- min-y (:y1 parent-selrect)) + :p2 (- min-x (:x1 parent-selrect))})] (cond-> {:layout-flex-dir direction :layout-gap layout-gap} (not (nil? padding))