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
{{ message }}
Repository navigation
Question: Respond to a click on the dragable item #591
@ofirgellerSMThe API allows constraining the activation via a delay or distance. Something like that:
// All of these are imported from '@dnd-kit/core'.constsensors=useSensors(useSensor(PointerSensor,{activationConstraint: {distance: 8,},}))<DndContextsensors={sensors}>// […]</DndContext>
Reacted by Andrea Riba, Benjamin Taylor, Ben, Klaas Landsman, 李环冀, Ralph, Jökull Sólberg Auðunsson, Omri Luzon, ofirgellerSM, Simão Garcia and 235 more
Reacted by Thijs Smudde, Ivan Ccama and TyIsI
Reacted by ofirgellerSM, zero_saiki, pablo delfante, adrian-asimov, Khiman Louer, ZIN KO MYINT, akos, yosi, Krishna Singh, Ivan Somov and 115 more
Reacted by Sandro, Krishna Singh, Jefry Dewangga, Ivan Somov, gio-oig, Alessandro Antoniolli, Qingxuan Luan, Nikola Delić, Budi Adiono, Gunjan Bangde and 59 more
Reacted by Naji Astier, Haider Waqar, Tatsuya Sasaki, Henrik, ab192130, harshit-cadmus, James Carlson, luisvargastrulyengaging, Mikhail Konin, Edgar Rodriguez and 20 more
Reacted by jackjie330, Stephane Willems, ab192130, lorkel, James Carlson, Kolade Afode, luisvargastrulyengaging, Mohamed Ahmedou, Patrick Burrows, Igor and 2 more
Reacted by osilsz, Tiago Alves, Mohamed Ahmedou, Prashant Shah, Mahmoud Hasanzadeh, EdsonMartinelli, Patrick Burrows, Igor, Rodolfo Goncalves, MeNoKVN and 2 more
@awgv's answer worked for me. But I encountered another problem. When I try to drag an element, the click functionality gets triggered and opens the popover component while also dragging the element. How can I avoid the click once a component is dragged?
Reacted by Johannes Vääräkangas, RAR and Amr Eraky
@awgv's answer worked for me. But I encountered another problem. When I try to drag an element, the click functionality gets triggered and opens the popover component while also dragging the element. How can I avoid the click once a component is dragged?
@awgv's answer worked for me. But I encountered another problem. When I try to drag an element, the click functionality gets triggered and opens the popover component while also dragging the element. How can I avoid the click once a component is dragged?
@chirag-9121
Ideally you should do a strict isDragging check for whatever function is being called. preventDefault() in general is not a good idea as it will completely block the bubble phase.
But depending on what you are doing, it might not have difference.
Activity
vladluca commentedon Jan 18, 2022
@ofirgellerSM You can find a solution to your problem here: #477
awgv commentedon Jan 20, 2022
@ofirgellerSM The API allows constraining the activation via a delay or distance. Something like that:
ani-ali commentedon Jan 2, 2024
this works perfectly with touch and drag
chirag-9121 commentedon Sep 11, 2024
@awgv's answer worked for me. But I encountered another problem. When I try to drag an element, the click functionality gets triggered and opens the popover component while also dragging the element. How can I avoid the click once a component is dragged?
aboveyunhai commentedon Nov 8, 2024
chirag-9121 commentedon Nov 9, 2024
The thing is shadcn's components are built on Radix, so the events gets triggered when the pointer is down, i.e.
onPointerDown.So I simply added this to the trigger component and the issue got resolved.
aboveyunhai commentedon Nov 9, 2024
@chirag-9121
Ideally you should do a strict
isDraggingcheck for whatever function is being called.preventDefault()in general is not a good idea as it will completely block the bubble phase.But depending on what you are doing, it might not have difference.
berksafran-wt commentedon Dec 3, 2024
It works for me. Thanks @chirag-9121 🙏
damassi commentedon Dec 22, 2024
Would be worth adding this solution clearly to the sortable docs 👍
feat(leads): promote 'cold' to active Kanban column + fix DnD drop op…