bvaughn / react-resizable-panels

https://react-resizable-panels.vercel.app/
MIT License
3.87k stars 135 forks source link

Drag gets priority over overlapping elements #296

Closed vanquishkuso closed 7 months ago

vanquishkuso commented 7 months ago

Hi, thank you for an awesome package!

I have an issue that I thought was similar to #288 but it doesn't seem to be fixed with the latest version 2.0.7. I have an overlapping button element that I want to be able to click and collapse a drawer. However, the draggable border gets priority even though the Z-index on the button is above.

This can be partially solved by moving the button outside of the resizable components (although it makes the positioning of the button troublesome), but when the button contains only an icon and not text, the drag gets priority again. The button is although still clickable.

If the button contains text and is outside of the resizable components it works as expected, but the positioning of the button is again cumbersome.

It's difficult to explain, so I reproduced a simple example it in the sandbox below: https://codesandbox.io/p/sandbox/react-resizable-panels-forked-s5jzpg

bvaughn commented 7 months ago

The behavior you're describing is controlled by this logic:

https://github.com/bvaughn/react-resizable-panels/blob/cd32d1c3d7c57bbb1f6430812aff7f0d75ee1d13/packages/react-resizable-panels/src/PanelResizeHandleRegistry.ts#L168-L204

This Replay shows what's happening: 8c5e2948-00d4-4dd0-a7f7-c11f660ee59f

Nearest I can tell, it looks like a bug in the stacking-order package, because it's returning a value indicating that your buttons are not "above" the drag-handle. I added a comment where I Think that library is broken, but I don't have time to dig into it more.

You could try reducing this test case even more and filing an issue in that project's GitHub? Or if you'd like to dig in yourself and submit a PR I'll try to find time to review it. I'm pretty swamped right now though with work and don't have time to dig into this more.

vanquishkuso commented 7 months ago

Thank you for the reply, I'll see what I kind find in that repo, in the meantime I'll try to use a workaround though.

bvaughn commented 7 months ago

I had a few minutes this morning so I made a smaller repro and filed https://github.com/Rich-Harris/stacking-order/issues/3

vanquishkuso commented 7 months ago

Wow thank you so much for taking the time to look at it! Very glad the problem could be located. Looking forward to their response and hopefully a fix since my workaround wasn't so good 😊.

bvaughn commented 7 months ago

No problem! Think I found a fix @ https://github.com/Rich-Harris/stacking-order/pull/4

bvaughn commented 7 months ago

Fixed published in 2.0.9


❤️ → ☕ givebrian.coffee

vanquishkuso commented 7 months ago

Amazing, thanks!