-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Stop click on _openPopup #3605
Stop click on _openPopup #3605
Conversation
Hmm, but why? I think I'd prefer to keep not bubbling up from markers the default. |
The map is an event target, so it's considered while traversing the DOM, and given that it listens for
Are we sure it's a problem (out of retrocompat) ? It's closer to DOM behaviour, no? |
@yohanboniface problem not in |
@ktoto (take this with caution, as it's not fully decided): with the current code when you listen to a click event and you don't want the map to also receive it, you are responsible of stopping it. |
@yohanboniface but before #3307 all be fine. I just want to understand why logic with map is changed? |
Just like in normal DOM, when an event is fired by an element, all its ancestors get it, unless |
I'd rather not follow DOM conventions and do an exception here, since I can't think of a use case where you'd want to trigger both map and marker on marker click, but people will have a very hard time adjusting to this breaking change. |
You mean exception for marker or for |
Exception for marker specifically, as opposed to vector layers and image overlays (which can be perceived as "click through" in some interfaces). |
OK, I'll do that asap :) |
@mourner only for |
@yohanboniface let's follow the 0.7.3 behavior here. |
options: { | ||
unpropagateEvents: '' // Space separated events that should not be propagated | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in Layer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hesitated ;)
0cd3868
to
4f10f2d
Compare
@@ -696,7 +696,8 @@ L.Map = L.Evented.extend({ | |||
for (var i = 0; i < targets.length; i++) { | |||
if (targets[i].listens(type, true)) { | |||
targets[i].fire(type, data, true); | |||
if (data.originalEvent._stopped) { return; } | |||
if (data.originalEvent._stopped | |||
|| (targets[i].options.nonBubblingEvents && targets[i].options.nonBubblingEvents.indexOf(type) !== -1)) { return; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately IE only supports array indexOf starting from 9. We'll probably have to iterate over the array in a loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gasp :/
Should I add a polyfill L.Util.inArray
for that? To make the code shorter here and more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe something like L.Util.indexOf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L.Util.indexOf
seems meaning it also will work on strings, is that what we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to keep only for arrays since string indexOf doesn't need an util method. It's an internal utility after all, we don't have to make it generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK done :)
Yeah, Chrome vs FF :/ |
OK, let's rebase now. |
Humm, not sure which moment :p Seems I've commit one second before to remove the use of Array.indexOf |
Nevermind :) |
720b02e
to
b20ffaa
Compare
b20ffaa
to
74018f2
Compare
Rebased and green :) |
Fix #3604.
I had a quick break.
Bubbling from marker is supposed to be the default, now, so I just stopped the event on
_openPopup
.I could also just add it on
bindPopup
, if you prefer this pattern.