mapbox / mapbox/mapbox-gl-geocoder
MapboxGeocoder query causing selection of first result if not matching current geocoder input.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 388
- Forks
- 181
- PR merge metrics
- No merged PRs in 30d
Description
I have a use case where I would like to show the Mapbox results when you focus the geocoder input.
To do this I set the placeholder text to the place_name of the result and check if the current geocoder input is equal to the placeholder. If it is I perform a query on the text to get the results dropdown to show.
This works great majority of the time but I have noticed if the 1st result is not the one in the current geocoder input if automatically selects it and flys to that location.
Can you explain why this is triggered?
I have setup a simple fiddle here: https://jsfiddle.net/qzarfdv2/
1. Enter your mapbox token
2. Enter 4870 in the geocoder input and select the first option
3. Click the map to lose focus
4. Click the geocoder input
Because some street result comes up as the first result something triggers it to go to that result automatically.
If you enter just about any other location and do the same steps you'll see that it just displays the dropdown suggestions and does not automatically select anything.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the MapboxGeocoder input and query behavior with the linked JSFiddle, especially the 4870 steps. Trace the query result handling that displays the dropdown and triggers selection or map movement; done means a nonmatching first result does not get selected or flown to automatically.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100