question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clicking on a result item passes the click event onto the map

See original GitHub issue

When 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:closed
  • Created 7 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
perliedmancommented, Oct 7, 2016

For me (Chrome 53/Ubuntu 16.04), changing from mousedown to click 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 since blur fires before click, so the result is removed before the click can reach it.

0reactions
perliedmancommented, Sep 21, 2016

@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/cc1a049617a3b03a181cb23305dcb297f7f155bf

Can’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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found