From 0bffca2dc72bd4d7cbd8284ff2ea69181887a6d2 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 8 Jan 2025 12:44:49 +0100 Subject: [PATCH] :bug: Fix unexpected exception on closing dropdown event Caused by a incorrect call to the internal dropdown component --- .../main/ui/components/context_menu_a11y.cljs | 4 +-- .../src/app/main/ui/components/dropdown.cljs | 27 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/frontend/src/app/main/ui/components/context_menu_a11y.cljs b/frontend/src/app/main/ui/components/context_menu_a11y.cljs index 546cec563b..a3f199ebb4 100644 --- a/frontend/src/app/main/ui/components/context_menu_a11y.cljs +++ b/frontend/src/app/main/ui/components/context_menu_a11y.cljs @@ -11,7 +11,7 @@ [app.common.data.macros :as dm] [app.common.schema :as sm] [app.main.refs :as refs] - [app.main.ui.components.dropdown :refer [dropdown']] + [app.main.ui.components.dropdown :refer [dropdown-content*]] [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] @@ -219,7 +219,7 @@ #(dom/focus! (dom/get-element (first ids))))) (when (and show (some? levels)) - [:> dropdown' props + [:> dropdown-content* props (let [level (peek levels) options (:options level) parent (:parent level)] diff --git a/frontend/src/app/main/ui/components/dropdown.cljs b/frontend/src/app/main/ui/components/dropdown.cljs index f27662421f..8da3f0b036 100644 --- a/frontend/src/app/main/ui/components/dropdown.cljs +++ b/frontend/src/app/main/ui/components/dropdown.cljs @@ -12,17 +12,13 @@ [app.util.keyboard :as kbd] [app.util.timers :as tm] [goog.events :as events] - [goog.object :as gobj] [rumext.v2 :as mf]) (:import goog.events.EventType)) -(mf/defc dropdown' - {::mf/wrap-props false} - [props] - (let [children (gobj/get props "children") - on-close (gobj/get props "on-close") - container-ref (gobj/get props "container") - listening-ref (mf/use-ref nil) +(mf/defc dropdown-content* + [{:keys [children on-close container]}] + (let [listening-ref (mf/use-ref nil) + container-ref container on-click (fn [event] @@ -57,10 +53,13 @@ children)) (mf/defc dropdown - {::mf/wrap-props false} - [props] - (assert (fn? (gobj/get props "on-close")) "missing `on-close` prop") - (assert (boolean? (gobj/get props "show")) "missing `show` prop") + {::mf/props :obj} + [{:keys [on-close show children container]}] + (assert (fn? on-close) "missing `on-close` prop") + (assert (boolean? show) "missing `show` prop") - (when (gobj/get props "show") - (mf/element dropdown' props))) + (when ^boolean show + [:> dropdown-content* + {:on-close on-close + :container container + :children children}]))