Просмотр исходного кода

fix: new option should be the first choice

Tienson Qin 3 дней назад
Родитель
Сommit
8ee2bc0ee9
1 измененных файлов с 3 добавлено и 5 удалено
  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)