daybrush / selecto

Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.
https://daybrush.com/selecto
MIT License
2.04k stars 82 forks source link

What would be the best approach to make buttons or other interactive elements available on selectable elements #101

Open Arjanno opened 1 year ago

Arjanno commented 1 year ago

Environments

Description

I have draggable elements that also contain buttons. Currently Selecto intercepts all mouse-clicks. Is there a way to have a higher zIndex or something like the checkinput hack to solve that the buttons have higher priority as Selecto?

daybrush commented 1 year ago

@Arjanno

It is not blocking the click, but blocking the drag.

In the dragStart event, if the target is a button, call stop().


onDragStart={e => {
   if (e.inputEvent.target.tagName === "BUTTON") {
      e.stop();
   }
}}
Arjanno commented 1 year ago

Awesome! That solved my problem.