fix autocomplete

pull/289/head
Pete Matsyburka 1 year ago
parent 1ceac968b0
commit c56f8cb38f

@ -25,7 +25,7 @@ class SubmittersAutocompleteController < ApplicationController
term = "#{params[:q].downcase}%" term = "#{params[:q].downcase}%"
submitters.where(column.matches(term, false, true)) submitters.where(column.matches(term))
else else
Submitters.search(submitters, params[:q]) Submitters.search(submitters, params[:q])
end end

@ -45,11 +45,7 @@ export default class extends HTMLElement {
this.currentFetch.then(async (resp) => { this.currentFetch.then(async (resp) => {
const items = await resp.json() const items = await resp.json()
if (q.length < 3) { resolve(items)
resolve(items.filter((e) => e[this.dataset.field].startsWith(q)))
} else {
resolve(items)
}
}).catch(() => { }).catch(() => {
resolve([]) resolve([])
}).finally(() => { }).finally(() => {

Loading…
Cancel
Save