Clicking on a result item passes the click event onto the map
See original GitHub issueWhen clicking on the drop down results, the click event is passed onto the map.
On line 206 of control.js I’ve changed:
L.DomEvent.addListener(li, 'mousedown', clickHandler, this);
to
L.DomEvent.addListener(li, 'click', clickHandler, this);
which resolves the issue.
On line 189 of control.js:
clickHandler = function clickHandler(e) {
L.DomEvent.preventDefault(e);
this._geocodeResultSelected(result);
};
preventDefault(e) prevents the mousedown
event propagating but not the click
event. I’m not sure if this is the best way to resolve it.
I’m working with the version 1.5.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
React - Render Item inside map function by click event
You need to pass the index of the item to your click handler. In your click handler, you can either do something which...
Read more >Simple Click Events | Maps JavaScript API - Google Developers
This example demonstrates the use of event listeners. It. listens for the click event on a marker to zoom the map when the...
Read more >JavaScript For Loop Click Event ← Issues & Solutions Explained
When you attach multiple click events inside a for loop in JavaScript, It always gives the last index regardless of what button is...
Read more >Element: click event - Web APIs | MDN
The MouseEvent object passed into the event handler for click has its detail property set to the number of times the target was...
Read more >On Click Event and Events Section | Mendix Documentation
If the microflow is triggered within a grid and has an object list parameter, the objects which are passed in the list depend...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For me (Chrome 53/Ubuntu 16.04), changing from
mousedown
toclick
does not fix the bug (still get a click event on the map), but also prevents the control from working - you can no longer select a result from the dropdown (presumably sinceblur
fires beforeclick
, so the result is removed before the click can reach it.@domialex if you read above, the problem with that approach is that it used to be
click
, but was changed since it caused problems: https://github.com/perliedman/leaflet-control-geocoder/commit/cc1a049617a3b03a181cb23305dcb297f7f155bfCan’t say for sure if that is still a problem or not, if it’s just a problem in some browsers, etc., but I’m wary of just changing this without some thorough testing. Personally, I’m sorry to say that I don’t have the time to do that at the moment, but help would be welcome!