unclecheese / react-selectable

A component for react that allows mouse selection of child items
MIT License
142 stars 72 forks source link

Disable _mouseDown handler for target in react-dnd #14

Closed rexpan closed 8 years ago

rexpan commented 8 years ago

This allow to use react-dnd with react-selectable. It ignore the elements that will be handle by react-dnd.

unclecheese commented 8 years ago

Nice catch. Cheers.

tfuda commented 7 years ago

Can you help me understand this change please? I'm trying to use react-selectable in an app that is NOT using react-dnd. It's not working for me. When I debug the code and left-click on the mouse button on one of the elements that is contained within my SelectableGroup I enter the _mouseDown handler, but it immediately returns because e.target.draggable is true. My project includes the following dependencies: http://screencast.com/t/nYm1yzjle9xE. Perhaps react-checkbox-group or react-date picker is doing something? Any thoughts on what might be setting the draggable property to true here? When I run your example, it works because draggable is false.

rexpan commented 7 years ago

I think we need a more robust way to handle scenario like this. Perhaps a optional function that tell _mouseDown to ignore the event or not.

<SelectableGroup shouldIgnoreMouseDown={checkMouseDown} .../>

function checkMouseDown(event, ...anythingElse) {
    return (!!event.target.draggable)
}

@unclecheese Please let me know what you think.

unclecheese commented 7 years ago

I agree, @rexpan. I think draggable is too use-case specific. There are probably a host of other conditions that would conflict with the mouseDown events.

In fact, we might even consider allowing blocking of all mouse events. There's probably some plugin out there that needs the mouseUp event, too. mouseMove is probably a stretch, though.

I'd be supportive of a change that provided props for blocking one or both of those.

Thanks for this, and sorry about the breaking change, @tfuda. (Go pats.)

tfuda commented 7 years ago

@rexpan @unclecheese Thanks for looking into this. As it turns out, I used your project for inspiration and then modified it to suit my needs. Go Pats!