fixing problems with slowness and fixing error with wrong locations.
This commit is contained in:
@@ -18,11 +18,12 @@
|
||||
]
|
||||
(r/create-class
|
||||
{:reagent-render (fn [{:keys [matches on-change field text-field value class not-found-description]}]
|
||||
(let [valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
|
||||
:when (str/includes? (.toLowerCase t) (.toLowerCase @text))]
|
||||
(let [text @text
|
||||
valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
|
||||
:when (str/includes? (.toLowerCase t) (.toLowerCase text))]
|
||||
match))
|
||||
valid-matches (if (and not-found-description @text)
|
||||
(concat valid-matches [[:not-found (not-found-description @text) (not-found-value @text)]])
|
||||
valid-matches (if (and not-found-description text)
|
||||
(concat valid-matches [[:not-found (not-found-description text) (not-found-value text)]])
|
||||
|
||||
valid-matches)]
|
||||
[:div.typeahead
|
||||
@@ -37,19 +38,19 @@
|
||||
false))}
|
||||
[:div.control
|
||||
[:div.tags.has-addons
|
||||
[:span.tag @text]
|
||||
[:span.tag text]
|
||||
[:a.tag.is-delete {:on-click (fn [] (select [nil "" nil]))}]]]]
|
||||
|
||||
[:input.input {:type "text"
|
||||
:class class
|
||||
:field field
|
||||
:value @text
|
||||
:value text
|
||||
:auto-focus auto-focus
|
||||
:on-blur (fn [e]
|
||||
(cond @selected
|
||||
nil
|
||||
|
||||
(#{"" nil} @text)
|
||||
(#{"" nil} text)
|
||||
nil
|
||||
|
||||
(seq valid-matches)
|
||||
@@ -71,16 +72,16 @@
|
||||
(select [nil (.. e -target -value)]))}
|
||||
])
|
||||
(cond
|
||||
(and (seq @text)
|
||||
(and (seq text)
|
||||
(not @selected)
|
||||
(seq valid-matches))
|
||||
[:div.typeahead-menu
|
||||
[:ul
|
||||
(for [[id t :as match] valid-matches]
|
||||
|
||||
[:li.typeahead-suggestion {:class (if (= id @highlighted)
|
||||
"typeahead-highlighted")
|
||||
:on-mouse-down #(do (select match))} t])]]
|
||||
(let [h @highlighted]
|
||||
[:div.typeahead-menu
|
||||
[:ul
|
||||
(for [[id t :as match] valid-matches]
|
||||
^{:key id} [:li.typeahead-suggestion {:class (if (= id h)
|
||||
"typeahead-highlighted")
|
||||
:on-mouse-down #(do (select match))} t])]])
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user