0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-10 17:18:21 -05:00

🐛 Fix error with keys on menu

This commit is contained in:
alonso.torres 2024-02-28 12:01:50 +01:00 committed by Andrey Antukh
parent ab2265d505
commit e636dc30c2

View file

@ -69,7 +69,7 @@
actual-index (d/index-of ids actual-id) actual-index (d/index-of ids actual-id)
previous-id (if (= 0 actual-index) previous-id (if (= 0 actual-index)
(last ids) (last ids)
(nth ids (- actual-index 1)))] (get ids (- actual-index 1) (last ids)))]
(dom/focus! (dom/get-element previous-id)))) (dom/focus! (dom/get-element previous-id))))
(when (kbd/down-arrow? event) (when (kbd/down-arrow? event)
@ -78,8 +78,9 @@
actual-index (d/index-of ids actual-id) actual-index (d/index-of ids actual-id)
next-id (if (= (- len 1) actual-index) next-id (if (= (- len 1) actual-index)
(first ids) (first ids)
(nth ids (+ 1 actual-index)))] (get ids (+ 1 actual-index) (first ids)))
(dom/focus! (dom/get-element next-id)))) node-item (dom/get-element next-id)]
(dom/focus! node-item)))
(when (kbd/tab? event) (when (kbd/tab? event)
(on-close))))] (on-close))))]
@ -100,5 +101,10 @@
(assert (fn? (gobj/get props "on-close")) "missing `on-close` prop") (assert (fn? (gobj/get props "on-close")) "missing `on-close` prop")
(assert (boolean? (gobj/get props "show")) "missing `show` prop") (assert (boolean? (gobj/get props "show")) "missing `show` prop")
(let [ids (obj/get props "ids")
ids (d/nilv ids (->> (obj/get props "children")
(keep #(obj/get-in % ["props" "id"]))))]
(when (gobj/get props "show") (when (gobj/get props "show")
(mf/element dropdown-menu' props))) (mf/element
dropdown-menu'
(mf/spread-props props {:ids ids})))))