-
Notifications
You must be signed in to change notification settings - Fork 3k
Support nested elements containing 'ui-sref' #592
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
Conversation
I'm curious if, while good for this scenario, it may create problems for other scenarios. I'm wondering if we need to handle it in a different way... like it seems in a lot of cases you want your events to bubble, so we'd essentially be turning that off for good and I just can't tell if that's going to be ok. |
That's the beautiful thing about Pull-requests, to get feedback on the feedback... now that you mention it, it may just have solved my specific case. Is there another way to flag the click as |
Yeah its almost as if we need the event to be like:
@sebnilsson Pretty sure that's what you were thinking too. |
I don't follow but feel free to implement a solution and we can review. |
Sorry for the previous, confusing comment. I'm happy with this Pull Request now :) |
Oh I was confused because I'm on mobile which doesn't show that you've updated the code. So now that I reviewed the code I agree it seems much better now. Just need @nateabele to review. |
Alternatively: <div ui-sref="root.child" ng-click="$event.stopPropagation()">
Child-detail
</div> Problem solved. Bonus: we're saved from the tedium & risk inherent in trying to guess at every future use case of everyone who ever uses this library. 🍻 |
That is of course a lot simpler, but shouldn't it be the default behavior? Maybe it's just my, so far, limited use of the framework, but is there any scenario when you actually want an |
The inherent assumption here is that order of priority is deterministic and fixed. While it is likely that what you mention above is often the case, (a) it would be significantly harder for people to work around the behavior in counter-examples than it would for you to use the solution I've suggested, and (b) I can't imagine that people are nesting |
I trust your judgement, but intuitively it feels like an |
@sebnilsson totally see your point, but also agree with @nateabele. How often do people nest anchor tags, I'm not sure I've ever done that. Don't think we don't appreciate your contributions though, sometimes things just need to be sat on for a while before we realize the right path forward. |
I totally agree, just trying to bring the problem to the surface. As for when you use nested anchor-tags: we use it to show larger boxes of company-info, where clicking the whole box goes into to the company-page, but clicking individual small icons inside the box gets you to the specific sub-area of the company-page, like ratings, videos, images and so on. Hope this whole thing has stimulated some thought around the problem, at least :) |
@sebnilsson Indeed. I think it warrants a note in the FAQ, explaining how the event cascade can be manipulated. |
Will do. |
Stopped event-propagation in the click-handler for uiSref-directive to support nested tags with
ui-sref
-attribute.Clicking the "Child-details"-link will fire the
root.child
-sref as expected, but also theroot
-sref immediately after, resulting in theroot
-state always being shown.