smeijer / leaflet-geosearch

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

Fix error being thrown when enter is pressed before any results are rendered #175

Closed olzraiti closed 4 years ago

olzraiti commented 6 years ago

To reproduce the bug:

  1. Go to https://smeijer.github.io/leaflet-geosearch/#google
  2. Type any place name to the geocoding input and hit Enter before the results are rendered
  3. Open the console to see the error (Uncaught TypeError: Cannot read property '-1' of undefined)

This bug happens because the leaflet control tries to select a result before the this.resultList in src/resultList.js isn't initialized yet. This pull request initializes this.resultList in the constructor.

smeijer commented 4 years ago

My apologies for the long wait. I'm working on a new release, and noticed that this bug has been fixed by #200. Sorry for not accepting this PR first.