question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useDraggable onMouseDown handler swallows element's onClick event

See original GitHub issue

Given the code below, the handleClick is never called. Removing {…listeners} fixes the issue. It appears the listeners.onMouseDown prevents propagation of the event.

<li onClick={handleClick} ref={setNodeRef} {...attributes}> {...listeners} <Content /> </li>

I’ve tried wrapping it with a div, wrapping Content with a div etc.

Any advice / pointers would be greatly appreciated.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
claudericcommented, May 27, 2021

Set an activationConstraint on the Mouse or Pointer sensor that is either based on distance or delay: https://docs.dndkit.com/api-documentation/sensors/pointer#activation-constraints

useSensor(PointerSensor, {
  activationConstraint: {
    distance: 10,
  },
});
1reaction
shauntrennerycommented, May 28, 2021

@clauderic for your reference: https://codesandbox.io/s/dndkit-k75i3?file=/index.tsx

It works 100% as expected. I’m trying to see what I’m doing wrong in my project.

Created a NextJS version as I assumed it could be related to SSR. Works as expected too. https://codesandbox.io/s/dndkitnext-tp03l

Read more comments on GitHub >

github_iconTop Results From Across the Web

OnClick event swallowed | WinForms Forums - Syncfusion
No, the sample uses the OnMouseClick() event. OnMouseDown() is used for the right button (to view the context menu). (Interestingly for the left...
Read more >
Why does jquery.blockUI swallow onClick event?
It logs every mousedown , mouseup , click and change event. It registers asynchronous change event handler on <input> thet does nothing for ......
Read more >
Custom Query – jQuery UI
When I use draggable on an img, it first does the browser's drag behavior, ... If I add a handler to the mousedown...
Read more >
Event delegation order - Hotwire Discussion
I add a mousedown event listener to the container to capture an interaction which does a “reorder in place”. This is done using...
Read more >
HTML5 CSS3 Genius Guide Volume 3 PDF - Scribd
Then, a click handler called 'Play' is then bound apply bespoke efects. to the button. The play function provides playing and HYPERREALITY
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found