Browse Source

Edit no results message method

CLDC-3787-Autocomplete-address-search
Manny Dinssa 1 week ago
parent
commit
9adfca117a
  1. 9
      app/frontend/controllers/address_search_controller.js

9
app/frontend/controllers/address_search_controller.js

@ -3,6 +3,7 @@ import accessibleAutocomplete from 'accessible-autocomplete'
import 'accessible-autocomplete/dist/accessible-autocomplete.min.css' import 'accessible-autocomplete/dist/accessible-autocomplete.min.css'
const options = [] const options = []
let currentQuery = ''
const fetchOptions = async (query, searchUrl) => { const fetchOptions = async (query, searchUrl) => {
try { try {
@ -52,7 +53,15 @@ export default class extends Controller {
defaultValue: '', defaultValue: '',
selectElement: selectEl, selectElement: selectEl,
minLength: 3, minLength: 3,
tNoResults: () => {
if (currentQuery && currentQuery.trim().length > 2) {
return 'No address found'
} else {
return null
}
},
source: (query, populateResults) => { source: (query, populateResults) => {
currentQuery = query
fetchAndPopulateSearchResults(query, populateResults, searchUrl, populateOptions, selectEl) fetchAndPopulateSearchResults(query, populateResults, searchUrl, populateOptions, selectEl)
}, },
autoselect: true, autoselect: true,

Loading…
Cancel
Save