Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing support for persistence of collapsed panels #234

Closed
hubgit opened this issue Dec 16, 2023 · 3 comments · Fixed by #235
Closed

Missing support for persistence of collapsed panels #234

hubgit opened this issue Dec 16, 2023 · 3 comments · Fixed by #235

Comments

@hubgit
Copy link

hubgit commented Dec 16, 2023

Given that react-resizable-panels supports both collapsible panels and persistence, there are a couple of gaps in support for persistence of collapsible panels that would be useful:

  1. The previous expanded size of a collapsed panel is stored in a ref, so is lost when the page is reloaded. A collapsed panel that's expanded after reloading the page only expands to the defined minimum size, rather than to the previous expanded size. It's possible to work around this by storing the expanded size in localStorage independently, and applying it when the panel is expanded, but it would be useful if the library supported this.
  2. It doesn't seem to be possible to both give a panel a default size and to say that it should be initially collapsed. If you set defaultSize to 0 (so it's initially collapsed) then the panel will only expand to its minimum size. It's possible to work around this by calling collapse() on the panel immediately, but it would be useful if the library supported this, perhaps with an additional prop for the initial collapsed state.
@bvaughn
Copy link
Owner

bvaughn commented Dec 16, 2023

  1. The previous expanded size of a collapsed panel is stored in a ref, so is lost when the page is reloaded. A collapsed panel that's expanded after reloading the page only expands to the defined minimum size, rather than to the previous expanded size. It's possible to work around this by storing the expanded size in localStorage independently, and applying it when the panel is expanded, but it would be useful if the library supported this.

I don't think it's a very high priority, but I do think this item could make sense to support.

  1. It doesn't seem to be possible to both give a panel a default size and to say that it should be initially collapsed. If you set defaultSize to 0 (so it's initially collapsed) then the panel will only expand to its minimum size. It's possible to work around this by calling collapse() on the panel immediately, but it would be useful if the library supported this, perhaps with an additional prop for the initial collapsed state.

This item doesn't make sense to me though.

If you want an item's initial size to be collapsed, then having it expand to the minimum size seems reasonable and expected. (If you want it to expand to some other size, you can use the resize(...) API rather than the expand() API.)

If you're talking about a previously rendered panel that was collapsed by the user, then it should be collapsed still after a reload, at which point I think we're really just talking about the first bullet point item above.

I think what you're saying is that you want a panel to be both collapsed by default and expandable by toggle (or expand() API) to some size that's greater than its minimum size. That's not a case I think I should build into this library, because it can be accomplished already with the imperative resize() API.

@bvaughn
Copy link
Owner

bvaughn commented Dec 16, 2023

1.0.3 supports the first item you mentioned. The second one should be done in user-space I think.

@hubgit
Copy link
Author

hubgit commented Dec 18, 2023

Thank you for implementing persistence for the expanded size, that's looking great.

It doesn't seem to be possible to both give a panel a default size and to say that it should be initially collapsed.

If you want an item's initial size to be collapsed, then having it expand to the minimum size seems reasonable and expected.

I think the expectation is that if an item's initial size is collapsed, then it should expand to the default size (or the persisted expanded size, if present). I think of the minimum size only as the point where a panel collapses while dragging to make it smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants