Skip to content

Commit

Permalink
Attempt to sort sub-command windows in Portal UI (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
fancygits authored Oct 18, 2024
1 parent 7c1ac63 commit 1a28bda
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/portal/ui/commands.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@
:reagent-render
(fn [] [:div {:ref #(reset! el %)}])}))))

(defn- try-sort
"Attempts to sort the given selection"
[coll]
(try
(sort coll)
(catch js/Error _
coll)))

(defn- selector-component []
(let [selected (r/atom #{})
active (r/atom 0)]
Expand All @@ -113,7 +121,7 @@
selected? @selected
on-close (partial close (state/use-state))
on-done (:run input)
options (:options input)
options (try-sort (:options input))
n (count (:options input))
on-select #(swap! selected (if (selected? %) disj conj) %)
on-toggle (fn toggle-all []
Expand Down Expand Up @@ -328,7 +336,7 @@
:or {component ins/inspector}
:as options}]
(let [theme (theme/use-theme)
options (filter-options options @filter-text)
options (try-sort (filter-options options @filter-text))
n (count options)
on-close (partial close (state/use-state))
on-select
Expand Down

0 comments on commit 1a28bda

Please sign in to comment.