mapbox / mapbox/mapbox-gl-geocoder

MapboxGeocoder query causing selection of first result if not matching current geocoder input.

Open
#363 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs discussion
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.