-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Fix to allow a form inside a dropdown toggle #324
Conversation
…ooking at https://github.com/twitter/bootstrap/blob/master/js/bootstrap-dropdown.js they stop click propagation from a form in the dropdown. Not sure if it is the best way to find the form but it is working.
Hi @lukemurray! Finally looking at this :-) I guess this works, but it seems messy. Thoughts @angular-ui/bootstrap? Also we will need a unit test showing that this fixes the bug you are talking about. |
It think this must be more general. Probably an optional attribute This way we can use the dropdown to keep multi-select options, datepicker, timepicker etc |
I like making it more customizable. And Yes it should have unit tests. Sorry I have been flat out. I'll jump on it this weekend. Thanks for the feedback |
I finally was working on my other project that was using this popup to show a login form and thought I'd make the change a little more generic like suggested. I wrote some tests, although I am quite new with karma so let me know if they're OK. You can now have an attribute close-on-click="false" on the dropdown-toggle element and it will prevent the dropdown from closing when clicking in the dropdown-menu area. The issue I had it finding the dropdown-menu element. I loop through the parent element items to find one with the class set. I thought about just using the second child but I'm not sure if the order for the dropdown-toggle and dropdown-menu is important or not. Let me know what you think. Cheers, |
|
@lukemurray This saved my day. Kudos. |
Refactor being worked on, #284 |
I guess no need to close this yet though, it is mergeable. |
OK, talked with Pawel and we decided that code needing refactor (original dropdown.js) should not have very specific fixes like this - it is able to cause more problems. Thanks for the work @lukemurray - even though it didn't get merged in you have shown us some problems with current implementation :-) |
That's OK. Will this be something that we can do in a future version? Or is ng-click="$event.stopPropagation" the way to go? To be hinest if the $event way works and I knew about it I wouldn't have done this change :) Seems there is still a lot to pick up about Angular. Cheers |
Looking foward for this merge. Until that i'm using stop-event directive; I think it's cleaner than $event.stopPropagation. |
Thank you for this ... saved my fanny big time :) |
Moving a login form to angular-ui bootstrap and it was not working. Looking at https://github.com/twitter/bootstrap/blob/master/js/bootstrap-dropdown.js they stop click propagation from a form in the dropdown.
Not sure if it is the best way to find the form (new to angular) but it is working for me.