Skip to content

Commit c167b69

Browse files
committed
enhance: select match
1 parent 82a1932 commit c167b69

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/main/frontend/components/select.cljs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,23 @@
144144
(not exact-match?)
145145
(not (string/blank? @*input))
146146
(not (exact-match-exclude-items @*input)))
147-
(->>
148-
(cons new-option search-result')
149-
(remove nil?))
147+
(let [current-input (exact-transform-fn @*input)
148+
matches? (some (fn [item]
149+
(and (string? item)
150+
(string? current-input)
151+
(string/includes?
152+
(string/lower-case item)
153+
(string/lower-case current-input))))
154+
(set (map (comp exact-transform-fn str extract-fn) search-result')))]
155+
(->>
156+
(if matches?
157+
(cons
158+
(first search-result')
159+
(cons
160+
new-option
161+
(rest search-result')))
162+
(cons new-option search-result'))
163+
(remove nil?)))
150164
search-result')
151165
input-opts' (if (fn? input-opts) (input-opts (empty? search-result)) input-opts)
152166
input-container (or

0 commit comments

Comments
 (0)