You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When implementing the experimental version, I stumbled upon something caused by the new design (having a DOM core library wrapped with React).
When having interactive elements using onPointerDown listeners inside a Draggable component, their listeners are never called (even when dragging is idle).
In the live demo, you can see that the first draggable's inner Button, bound on onPointerDown is never triggered, while the second one, bound on onPointerDownCapture is.
Analysis
This is caused because @dnd-kit's pointer sensor is bound to the HTML element while React's event handlers are bound to the root app element (root.render(<App />)) through Event Delegation.
The PointerSensor is stopping event propagation here:
We are using another library (radix-ui primitives) which binds the dropdown trigger to onPointerDown. We can't objectively ask them to change their listeners to onPointerDownCapture to mitigate this design flaw.
What do you suggest a solution could be?
I can help with a PR with great pleasure.
Happy holidays,
The text was updated successfully, but these errors were encountered:
Hello @clauderic, thank you so much for your slick library.
Context
Issue
When implementing the experimental version, I stumbled upon something caused by the new design (having a DOM core library wrapped with React).
When having interactive elements using
onPointerDown
listeners inside aDraggable
component, their listeners are never called (even when dragging is idle).In the live demo, you can see that the first draggable's inner Button, bound on
onPointerDown
is never triggered, while the second one, bound ononPointerDownCapture
is.Analysis
This is caused because
@dnd-kit
's pointer sensor is bound to the HTML element while React's event handlers are bound to the root app element (root.render(<App />)
) through Event Delegation.The PointerSensor is stopping event propagation here:
dnd-kit/packages/dom/src/core/sensors/pointer/PointerSensor.ts
Line 128 in f3f05ba
It makes sense because we would expect the listeners to be called in the following order:
button.onPointerDownCapture
button.onPointerDown
parentDraggable.onPointerDown
.However, because React delegates events to
root
, they are called in that order:button.onPointerDownCapture
parentDraggable.onPointerDown
button.onPointerDown
.The aforementioned stopped propagation is making it impossible to call
button.onPointerDown
Follow-up
We are using another library (
radix-ui
primitives) which binds the dropdown trigger toonPointerDown
. We can't objectively ask them to change their listeners toonPointerDownCapture
to mitigate this design flaw.What do you suggest a solution could be?
I can help with a PR with great pleasure.
Happy holidays,
The text was updated successfully, but these errors were encountered: