leaflet-geosearch icon indicating copy to clipboard operation
leaflet-geosearch copied to clipboard

autoComplete: false not work (expected enter key)

Open ChR-iSz opened this issue 3 years ago • 2 comments

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...

ChR-iSz avatar Oct 04 '22 07:10 ChR-iSz

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.

smeijer avatar Oct 04 '22 19:10 smeijer

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();
}

dmx-patrick avatar Jun 04 '24 13:06 dmx-patrick