gridstack.js icon indicating copy to clipboard operation
gridstack.js copied to clipboard

H5: clicking on child button still drags parent item - no way to cancel in dragStart

Open MojoDK opened this issue 4 years ago • 1 comments

Subject of the issue

How can I cancel the drag event? If i drag a component inside the GridStack item, then the whole item is dragged. It seams like the "dragstart" event has a bubbles property where I can check if it bubbles - but I don't se anyway to cancel the dragging?

Your environment

GridStack: 4.2.5 jQuery: 3.6.0 Browser: Microsoft Edge Windows x64

Steps to reproduce

Place an item inside a stack-item-content (like a button) and when I drag the button itself, the dragstart event is raised and the event.bubbles is true ... but how can I cancel the drag event? https://jsfiddle.net/upcjegsk/1/

Expected behavior

I hoped for a event.cancel = true in the dragstart event.

Actual behavior

Can't find any way to cancel the draggin.

MojoDK avatar Jun 04 '21 12:06 MojoDK

if you use the JQ version (which uses mouse click events rather than HTML5 draggable) then the button will eat the events and the grid item will not drag... this is a difference in behavior, so a bug. My long term is to use pointer + touch event instead of draggable after all (see #1757 )

https://jsfiddle.net/adumesny/gbnf1zuc/

I see you list jquery 3.6 so you are already using JQ ? you will have to use our bundled version for now (or go back to 1.x) as I have not figured out how to bundle it for external imports instead. My focus is not JQ these days...

adumesny avatar Jun 04 '21 14:06 adumesny

we don't use draggable in v6 so closing

adumesny avatar Sep 18 '22 00:09 adumesny