perliedman / leaflet-control-geocoder

A simple geocoder form to locate places. Easily extended to multiple data providers.
http://www.liedman.net/leaflet-control-geocoder/
BSD 2-Clause "Simplified" License
563 stars 221 forks source link

Stop propagation on keydown enter #228

Open Garito opened 5 years ago

Garito commented 5 years ago

Hi! I'm trying to use this library as a field in a form but when I type enter to accept a suggestion it adds the marker as expected but bubbles the event to my form which then submits the result

I've been checking the code and I guess we could prevent this by adding a stopPropagation @ https://github.com/perliedman/leaflet-control-geocoder/blob/c5751fd78de2e71a813cf4744eca61965751e0eb/src/control.js#L335

I have no interest in a particular implementation, I only need to prevent this effect (in case the stopPropagation thing is not the good one)

What do you think? Thanks

perliedman commented 5 years ago

Hi!

Using the control as part of a form is a bit outside the scope of the plugin, and I am reluctant to make changes to cater for rare use cases.

Having said that, if this is important to you and you feel like you have the time to test the implications of this for more normal use cases, I would be open to a PR like this. Just make sure such a change doesn't break normal use of the control!

burritojustice commented 4 years ago

I'm running into a similar situation, but where entries in the geocoder field are triggering keyboard shortcuts on my Leaflet-based app.