fix autocomplete

This commit is contained in:
Pete Matsyburka
2024-05-30 23:38:38 +03:00
parent 1ceac968b0
commit c56f8cb38f
2 changed files with 2 additions and 6 deletions
@@ -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(() => {