marceljuenemann / angular-drag-and-drop-lists

Angular directives for sorting nested lists using the HTML5 Drag & Drop API
MIT License
2.16k stars 712 forks source link

Bootstrap dropdown does not work inside draggable element #241

Open ianmh opened 8 years ago

ianmh commented 8 years ago

I'm assuming this is because the Bootstrap dropdowns use list elements. Is there a workaround for this?

ianmh commented 8 years ago

So I have narrowed down the issue to this piece of code. The event.stopPropagation(); is preventing events from registering with Bootstrap UI dropdowns. I have removed this line in my code but I'm not sure of the implications.

I should also add that not only do they work inside draggable elements now, but also when you click on a draggable element Bootstrap drop downs now properly close if they were open. I use a Bootstrap dropdown to also add draggable elements, before this change they would not close if you clicked on a draggable element.

      /**
       * When the element is clicked we invoke the callback function
       * specified with the dnd-selected attribute.
       */
      element.on('click', function(event) {
        if (!attr.dndSelected) return;

        event = event.originalEvent || event;
        scope.$apply(function() {
          $parse(attr.dndSelected)(scope, {event: event});
        });

        // Prevent triggering dndSelected in parent elements.
        // event.stopPropagation();
      });

https://github.com/marceljuenemann/angular-drag-and-drop-lists/blob/master/angular-drag-and-drop-lists.js#L169

ianmh commented 8 years ago

This issue is fixed with this pull request by rysilva.

https://github.com/marceljuenemann/angular-drag-and-drop-lists/pull/132/commits/4a788552dec7730e656677a7ca33f9c8688a5406

Update: Correction, this does not fix the issue.

Den-dp commented 7 years ago

Same here, @ianmh any workarounds?

ianmh commented 7 years ago

@Den-dp I can't seem to duplicate the issue I was having anymore, but I have used dnd-nodrag attribute on the dropdowns. This might fix it.

Den-dp commented 7 years ago

It's still pretty simple to reproduce http://plnkr.co/edit/nuQ8QQr3NsSPv6Cs1N8G?p=preview

ianmh commented 7 years ago

Your example works for me, although they don't toggle / close, is that the issue?

Edit: I'm using a really old version of bootstrap and dropdown-toggle is working for me.

Den-dp commented 7 years ago

although they don't toggle / close, is that the issue?

Yes, this is my issue.

I'm using a really old version of bootstrap and dropdown-toggle is working for me.

Hey, but what about living on the bleeding edge? 😉

mshriner commented 5 years ago

Any updates on this?