From 9d8b7bc25c9dd0a02ab644cd93c79ba28d4994ab Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 20 Nov 2023 13:47:59 +0100 Subject: [PATCH] :bug: Fix swap sidebar keeps opened for main component after making 'Restore main' or 'Show main' --- .../sidebar/options/menus/component.cljs | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index e1c62f344..d1e21ec47 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -17,7 +17,6 @@ [app.main.data.workspace.specialized-panel :as dwsp] [app.main.refs :as refs] [app.main.store :as st] - [app.main.ui.components.context-menu :refer [context-menu]] [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.radio-buttons :refer [radio-button radio-buttons]] [app.main.ui.components.search-bar :refer [search-bar]] @@ -386,23 +385,19 @@ [:& component-group-item {:item item :on-enter-group on-enter-group}]))]]])) (mf/defc component-ctx-menu - [{:keys [menu-entries on-close show type] :as props}] - (case type - :context-menu - [:& context-menu {:on-close on-close - :show show - :options - (vec (for [entry menu-entries :when (not (nil? entry))] - [(tr (:msg entry)) (:action entry)]))}] - :dropdown - [:& dropdown {:show show :on-close on-close} - [:ul {:class (stl/css :custom-select-dropdown)} - (for [entry menu-entries :when (not (nil? entry))] - [:li {:key (uuid/next) - :class (stl/css :dropdown-element) - :on-click (:action entry)} - [:span {:class (stl/css :dropdown-label)} - (tr (:msg entry))]])]])) + [{:keys [menu-entries on-close show] :as props}] + (let [do-action + (fn [action event] + (dom/stop-propagation event) + (action))] + [:& dropdown {:show show :on-close on-close} + [:ul {:class (stl/css :custom-select-dropdown)} + (for [entry menu-entries :when (not (nil? entry))] + [:li {:key (uuid/next) + :class (stl/css :dropdown-element) + :on-click (partial do-action (:action entry))} + [:span {:class (stl/css :dropdown-label)} + (tr (:msg entry))]])]])) (mf/defc component-menu @@ -491,8 +486,7 @@ [:& component-ctx-menu {:show menu-open? :on-close on-menu-close - :menu-entries menu-entries - :type :dropdown}]]) + :menu-entries menu-entries}]]) (when (and can-swap? (not multi)) [:div {:class (stl/css :component-parent-name)} (cfh/merge-path-item (:path component) (:name component))])]]