dnd-kit
dnd-kit copied to clipboard
Weird Styling behaviour of draggable on passing sensor activator options.
Why i am using this packages? Very simple use case. In my application i have multiple cards which any user can drag and drop to another section.
- Scenario 1 - Passing no Constraints to the sensor.
- Scenario 1 - Passing Constraints to the sensor.
Scenario 1
- If i have passed any sensor i.e. Pointer, Mouse Touch or keyboard without any constraint like delay or distance then dragging and draggable item styling is working fine but I have multiple CTA's on card which are not working now as i didn't passed any constraints as soon as i click on them the Dragging event starts. Scenario 1 is working as expected as i am not passing any constraint.
Attaching screenshots have a look at the values that i am getting inside onDragStart
Scenario 2
- If i passed any of the constraint in sensors in that case the draggable card top, left, bottom, width, height of draggable set to 0 and dragging start from that position which is weird.
Attaching screenshots
I am not sure why in scenario 2 the styling of draggable item is set to zero. Can you guys help me whether its something that i am doing wrong or there is a bug present in this scenario.
Hi @clauderic, Can you have a look at the above scenarios and help me in resolving this problem?
Hi @gurpreet013, could you provide a CodeSandbox replicating the issue you are facing?
We are having the same issue. In our scenario we use a virtualised list which positions all elements at top:0 left:0 and translates them to their actual position. Using a mouse sensor with distance constrains breaks this solution. I hope i find the time to create a minimal example this week.