smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.02k stars 270 forks source link

autoComplete: false not work (expected enter key) #347

Open ChR-iSz opened 1 year ago

ChR-iSz commented 1 year ago

Hello,

i don't want the autocomplete option. I don't spam the provider every 250ms.

So, my Question, if i set autoComplete: false, the search result if i press enter is not showing. If i press enter, it looks the map center to the first result. But i don't see the dropdown results if i press enter...

smeijer commented 1 year ago

That's working as its (currently) intended. If you don't want to spam the server every 250ms, but do want to show suggestions, you'll need to increase the autoCompleteDelay duration.

dmx-patrick commented 1 month ago

In the onSubmit method the resultList is cleared but this is only available when autoComplete is enabled and throws an error when setting autoComplete option to false.

https://github.com/smeijer/leaflet-geosearch/blob/9197b372c28277ff81a28af2afa360fc33d16bc0/src/SearchControl.ts#L385

Suggested solutions:

Call the clearResults method instead of directly clearing the resultList

this.clearResults();

or check the autoComplete option first before calling the clear

const { autoComplete } = this.options;

if (autoComplete) {
  this.resultList.clear();
}