Open AJB99 opened 4 years ago
Hi AJB99, I'm experiencing a similar problem.
Regarding your Question #1, I've had success with putting stopPropagation on the mouseup event. Regarding your Question #2, I also do not know.
Extending on your problem, I've found another issue. After you've successfully stopped the proagation, it seems to resume on the next click. I modified this example to demonstrate the issue: https://jsbin.com/kemezohuva/edit?html,js,console,output
Notice, the clicking on the "Test" button does not select the Item. However, as soon as you something else on the page, Item 2 becomes selected. I'd love any feedback on how to prevent this from happening.
Thanks
Any updates about this issue ?
It's currently not possible to click on a child element without selecting the grid element. For example, a delete button will call the function to delete but will select the element of grid and keep it as selected. I tried of course to stop the propagation but without success.
Version 1.10.2
The Issue I'm using Sortable.js to build a draggable tree component. Which means each of my
sortable-item
s has atoggle-arrow
as a child element that opens and closes asub-tree
(if there is one).I'm attempting to use
stopPropagation()
to prevent the selection of the parentsortable-item
if thetoggle-arrow
is clicked, but it's not working.It looks like this when closed:
And looks like this when open:
The blue highlight you see in the open state (the second image) is the styling I've chosen for the
selectedClass
option when using themultiDrag
plugin.This is illustrating that when I click on the
toggle-arrow
it results in the parentsortable-item
being selected.I don't want this to happen.
The Code The code for an item in my Sortable.js tree component looks like so (using Vue.js, and Pug syntax):
And then I've got a handler for the
@click
binding on mytoggle-arrow
element:You can see that I'm declaring
@click.stop
as the event binding, which should stop theclick
event from bubbling up from thetoggle-arrow
child element, but it's not working. I'm even attempting to use$event.stopPropagation
within the handler. But, the event seems to continue to bubble, and thus the parentsortable-item
element ends up in a selected state.Questions
How do I stop propagation of an event when a child element of my
sortable-item
is clicked?How is selection handled by the
multiDrag
plugin? I dug through the code and saw that theselect
event is fired within the handler of thedrop
event of thesortable-item
, but I'm confused by that. Why is thedrop
event handler being used to toggle selection of asortable-item
?Thanks in advance for any light you may be able to shed on this.