SamSamskies / react-map-gl-geocoder

React wrapper for mapbox-gl-geocoder for use with react-map-gl
MIT License
122 stars 29 forks source link

Suggestions are displayed after setting a default input #118

Open victorneuret opened 3 years ago

victorneuret commented 3 years ago

I had been working with the Geocoder outside of the map. When I set the input value, the Geocoder is loaded with it's suggestions and they do not collapse until i clic on the geocoder and then clic out. I would like to know how to load the geocoder without the suggestions until the user select the geocoder. I may have done something wrong. Here is how I have done it: https://codesandbox.io/s/pedantic-gauss-hhdrl?file=/src/App.js

SamSamskies commented 3 years ago

It didn't use to do that. Unfortunately, mapbox-gl-geocoder changed the behavior https://github.com/mapbox/mapbox-gl-geocoder/issues/401. You might be able use some CSS wizardry to hack around this. Like maybe hide the suggestions unless the input is focused or something.

It might be worth it to roll your own geocoder component to fully customize how it works. You could fetch the data using the Mapbox API and then hook that up to your custom component.

SamSamskies commented 3 years ago

You could also try rolling back to v2.0.13 which I think was using a version of mapbox-gl-geocoder that didn't display the suggestions when setting the input value.

victorneuret commented 3 years ago

Thanks for your answer. I understand that it is not possible for you to fix anything within this package. I'll see what I can do