bvaughn / react-resizable-panels

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

Feature Request: Panel Size Memory #319

Closed BrodyRas closed 3 months ago

BrodyRas commented 3 months ago

When programmatically collapsing a panel, the previous size is remembered. So when I programmatically expand the panel, it returns to that initial size. This is a very useful feature. However, this doesn't work as expected if the previous size was 0, in which case, the panel will "expand" to it’s last size of 0, seemingly doing nothing.

Is there a way to check what the size of the panel was before collapsing? This way, I can conditionally check if it was 0, and instead of "expanding", resize the panel to 10 or something.

bvaughn commented 3 months ago

Calling panel.expand() should expand to the minimum size. If your panel's minimum size is 0 then I guess that wouldn't work, but then again the panel isn't really "collapsed" in that state (at least not how this library defines "collapse")

Can you share a repro please? (Small example project on Code Sandbox or something that demonstrates the behavior you're describing.

BrodyRas commented 3 months ago

Sorry for delay, I wasn't able to reproduce the issue as described, but using the setLayout method, I was able to find a suitable workaround. Thanks!

bvaughn commented 3 months ago

Thanks for following up!