Parcourir la source

fix: new option should be the first choice

Tienson Qin il y a 2 jours
Parent
commit
8ee2bc0ee9
1 fichiers modifiés avec 3 ajouts et 5 suppressions
  1. 3 5
      src/main/frontend/components/select.cljs

+ 3 - 5
src/main/frontend/components/select.cljs

@@ -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)