Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geocoder input is left uncollapsed after selecting an item #183

Open
mvl22 opened this issue Oct 27, 2024 · 2 comments
Open

Geocoder input is left uncollapsed after selecting an item #183

mvl22 opened this issue Oct 27, 2024 · 2 comments

Comments

@mvl22
Copy link

mvl22 commented Oct 27, 2024

When auto-collapsing is used, when the user clicks on a result, the box is left open. It should be auto-closed, as the user has made a definitive decision and the action is complete.

I have created a workaround, but this is unsatisfactory because it force-clears the input:

// Auto-close on select; see: https://maplibre.org/maplibre-gl-geocoder/classes/default.html#on
geocoder.on ('result', function () {
	document.querySelector ('.maplibregl-ctrl-geocoder--button').click ();    // Click to remove the search value
	document.querySelector ('.maplibregl-ctrl-geocoder--input').blur ();      // Move away from the search box
});

I tried using the _collapse method, which seems to be advertised as public despite the underscore, but this had no effect, as I see its internal implementation ignores the call if there is focus.

@HarelM
Copy link
Collaborator

HarelM commented Oct 28, 2024

"advertise as public" is probably an incorrect documentation migration due to the migration to typescript, _ methods are private.

Can you link to a jsbin showcasing this issue?

@mvl22
Copy link
Author

mvl22 commented Oct 29, 2024

Reproduce case:

  • Go to this Codepen example I found: https://codepen.io/tsamaya/pen/KKxGwLj
  • In the Javascript, add collapsed: true to the example given, in the new MaplibreGeocoder options parameter
  • The map will load below, with the control collapsed by default
  • Hover over the control
  • Click in the geocoder input box
  • Type a location, e.g. Paris, and press return
  • [The map will go to the first location, and place a marker, which is a very odd behaviour but that's a separate problem]
  • Click on the drop-down that appears, to select a desired item
  • The map moves to that location
  • The box is left open, even though the user has made a selection. The user has to erase the contents, and then blur away, in order to get rid of it, which is not intuitive.

The last step should not be necessary - selection of an item from the drop down should auto-close the control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants