fix: new option should be the first choice

This commit is contained in:
Tienson Qin
2025-12-24 16:45:47 +08:00
parent e5982b678d
commit 8ee2bc0ee9

View File

@@ -138,16 +138,14 @@
(not (contains? selected-choices (:value item))))
search-result')
search-result')
new-option {:value @*input
:label (str "+ New option: " @*input)}
search-result (if (and show-new-when-not-exact-match?
(not exact-match?)
(not (string/blank? @*input))
(not (exact-match-exclude-items @*input)))
(->>
(cons
(first search-result')
(cons {:value @*input
:label (str "+ New option: " @*input)}
(rest search-result')))
(cons new-option search-result')
(remove nil?))
search-result')
input-opts' (if (fn? input-opts) (input-opts (empty? search-result)) input-opts)