mirror of
https://github.com/penpot/penpot.git
synced 2025-03-14 16:51:18 -05:00
🐛 Fix unexpected exception on closing dropdown event
Caused by a incorrect call to the internal dropdown component
This commit is contained in:
parent
2d955a2256
commit
0bffca2dc7
2 changed files with 15 additions and 16 deletions
|
@ -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)]
|
||||
|
|
|
@ -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}]))
|
||||
|
|
Loading…
Add table
Reference in a new issue