tomkp / react-split-pane

React split-pane component
https://tomkp.github.io/react-split-pane
MIT License
3.23k stars 408 forks source link

Pass event to onChange, onDragStarted, and onDragFinished handlers #217

Open cdtinney opened 7 years ago

cdtinney commented 7 years ago

onChange and onDragFinished only receive the size of the primary pane. onDragStarted receives nothing.

I have a use case where the DOM element that contains the SplitPane is draggable. If the user starts a drag on the resizer, though, it should be locked. It would be helpful to simply prevent propagation of the event from the onDragStarted handler.

It could be added as the second argument to prevent a breaking change.

silicakes commented 5 years ago

I was about to open the same issue. I'm aware that there's a V2 in progress and this might not be a priority, but I've created a PR to address this issue https://github.com/tomkp/react-split-pane/pull/351 @tomkp - You think you'll be able to have a look?

For the time being - here's a quick fix:

function handleMouseDown(evt) {
  const isResizer = evt.target.classList.contains('Resizer');
  if (isResizer) {
    evt.stopPropagation();
  }
}
<div onMouseDown={handleMouseDown}>
  <Draggable...
    <SplitPane...
  </Draggable>
</div>