bvaughn / react-resizable-panels

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

Window resize collapses panels erroneously when using pixels #210

Closed psychedelicious closed 10 months ago

psychedelicious commented 10 months ago

v57 Repro: https://codesandbox.io/p/sandbox/erroneous-collapse-on-window-resize-lhdnc4

Resize the window, making it smaller horizontally. The panels collapse immediately, despite there being plenty of room for them.

In this example, I've made the min and max sizes the same to make the issue very obvious, but the same behaviour occurs when they are different - you just need to shrink the window down a bit more.

I added a resizeobserver to the panel content, logging the width to console. It appears that for a brief moment during a calculation during window resizing, the panel's width dips below its minSizePixels, triggering the collapse.

bvaughn commented 10 months ago

Thanks for the repro.

Here's a Replay I made of the repro you shared: https://app.replay.io/recording/6c38db67-2a7a-4736-9a34-f8fb9772d9b6

I'll look into it and add some comments there.

psychedelicious commented 10 months ago

Np. Do you mind making the replay public?

bvaughn commented 10 months ago

Ooops. My apologies. it's public now.

bvaughn commented 10 months ago

Thanks for the bug report. I think #215 should fix this (and a few other issues I discovered while testing).

bvaughn commented 10 months ago

react-resizable-panels@0.0.58 has been published with this fix