-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Reconsider stopPropagation in view triggers #2926
Comments
stopPropagation
in view triggers
Better idea: Instead of a "breaking change" just add some sort of options for the trigger to set stopProp to false for certain triggers as needed. |
There are already options for @JSteunou are you suggesting leaving I'm not entirely aware of the caveats of changing the defaults. Makes me a little nervous. |
It's clearly a call for a breaking change. If some people relied on that feature to stop an event to bubble up to a parent view, they only be concerned if they listened that event on the parent view and want the event specifically come from that parent layout and not from the child. But I do think that case is minor compared to normal use case, and so default value should represent majority. I'm really interested to know people usage of this feature and see if I'm the only one seeing that or if I'm totally wrong. My PoV is obviously tight to the apps I'm writing. |
@marionettejs/marionette-core could this be considered for v3? I am afraid it will not be after v3 go out because it introduces a breaking change. Again, from my experience, I had the case again today with a co-worker, not understanding why its link |
I still am unaware of the caveats and don't feel comfortable pushing for either direction, but I have an idea. Why don't we implement this with a feature flag? We can add a feature flag that changes the default for v3.. (or even v3.x) then if it seems to work fine we can swap the default for v4.. and if there are no major complaints we could remove the flag altogether for v5 |
In examining our own codebase, we found that 65% of all use of triggers included overriding the default stopPropagation flag, and further, many, many instances where we'd avoided using triggers because of the default behavior being confusing. In our case at least, it doesn't seem like that great of a default setting. |
That reassuring. I wouldnt push this change too much so far because I though I was the only one bothered by this. |
PR welcomed.. I'd still say this is an excellent candidate for a breaking change behind a feature flag for |
So I just realized why It is specifically talking about But I believe So now more than ever I think #2975 is important and we should discourage using That said, I'd still support a flag for changing the default.. But I think now I'm leaning towards leaving it |
What could solve all those cases:
|
The 2nd 2 are in PR #3261. The first one is a bit complicated. At least when looking into it, the solution wasn't immediately clear. Also this would be one of the first instances where we would modify how backbone works. I think it would be interesting to see if backbone would accept a PR for this. In the very least they could speak to the downsides. |
Here's a comment from backbone on this: jashkenas/backbone#1354 (comment) However I still don't know how any of this works without stopPropagation unless the developer handles each case individually. Backbone events are delegated from the
At that point I don't know a generic solution other than So I maintain my argument that we forward the event argument and we have a feature flag for Am I missing a solution that works for the general case without leaving the user open to very confusing unexpected bugs? |
Maybe it's possible to flag the event in the first callback so when passing to another callback it can be obvious it does not came from this view but a child view. |
Oddly that is what jquery is doing with stopPropagation. |
That would be our own stopPropagation at Backbone / Mn level without interfering with the one at jQuery / Native DOM level. I very like this idea. |
Will we still need a way to turn it off? I would assume so? Or maybe not? This'll definitely be a breaking feature. Not sure if anyone is depending on the jquery propagation that this wouldn't cover, but certainly possible. I am ok with turning off What's a little odd about this in general is that backbone view |
I might open a new issue about the idea of fixing backbone event delegation lake of target check by using view.cid but the main point of this discussion was fixed by #3261 |
View triggers actually set
stopPropagation
totrue
by default. I do not know why this was set at first, but from my pov it's a real pain. I have a lot of views inside region triggering events on click for parent of behavior to listen, and when that parent or another parent far above have to listen a click too, I fall into the usual trap: click is stopped by view triggersstopPropagation
.Can we re-discuss that behavior and maybe change it for v3 as a breaking change?
The text was updated successfully, but these errors were encountered: