Comments (11)
Sorry but I'm not sure what you're describing.
from react-resizable-panels.
In the reproduction example, if both panels are showing and collapsed, if I hide the left panel, the right panel it's going to expand instead of being collapsed. Is this the expected behavior?
from react-resizable-panels.
In the reproduction example, if both panels are showing and collapsed, if I hide the left panel, the right panel
If both panels are collapsed, then how can you hide the only remaining panel? This is what I don't understand about the original description.
from react-resizable-panels.
I have the state of both left
and right
panels collapsed and showing, like in the image below:
When I hide the left
panel, for example, instead of the right
panel remain collapsed and the middle
occupy all the space, the opposite occurs, the right
panel uncollapse like in the image below:
My point is that I think the middle
panel would fill in the space and the right
panel would remain collapsed. Is this more clear?
The same occurs for hiding the right
panel. The left
panel uncollapses.
from react-resizable-panels.
Ah, I see where the disconnect is now. When you say you "collapse" the panel, you're actually removing it entirely (conditional rendering).
The group shows the right panel in that case because this library stores layouts differently for different combinations of panels. (This is discussed in depth in on issue #260, particularly this comment #260 (comment)) tl;dr layouts must be stored separately because of validation edge cases
I think you could accomplish the effect you're looking for by changing the panel's constraints, so that it stays mounted but becomes hidden, e.g.
<Panel
className={styles.Panel}
id="left"
minSize={showLeftPanel ? 10 : 0}
maxSize={showLeftPanel ? undefined : 0}
order={1}
collapsible={true}
collapsedSize={showLeftPanel ? 10 : 0}
>
<div className={styles.Centered}>left</div>
</Panel>
I think this approach should work for you. Hope this helps!
❤️ → ☕ givebrian.coffee
from react-resizable-panels.
Tried this on the reproduction and seems to not work
from react-resizable-panels.
I can't really help with screenshots, mate. There's nothing to debug.
I think at this point, it would be easiest for me if you sent a Replay of what you're seeing so I can look at it exactly. Barring that, send an updated Code Sandbox or something.
from react-resizable-panels.
So If I understand correctly the state of the panels in saved in relation of the conditionals panels. If I have a x
collapsed panel when a y
panel is rendered and the same x
uncollapsed panel when the same y
is not rendered, the x
panel it's going to be toggled between collapsed and uncollapsed, instead of remaining in his last state?
from react-resizable-panels.
If you have a group with two (or more) possible layouts, the default layout as well as the saved layout are initialized and stored separately for each combination of panels. (This is necessary for reasons I tried to explain in #260.)
If you want the layout to appear to stay the same between different panel combinations, then either you need to (a) use the imperative API to set it yourself after conditionally rendering a different set of panels or (b) use an approach like I mentioned above to hide a panel without conditionally rendering it.
from react-resizable-panels.
Ok. I got it now.
I will test with the imperative API to achieve what I want.
Thanks for the time to explain how the state works and thanks for this amazing library.
from react-resizable-panels.
You're welcome 😄 Good luck!
from react-resizable-panels.
Related Issues (20)
- Collapsed state resets when new values are provided to collapsedSize/minSize HOT 4
- Version 2.0.0 onClick regression HOT 1
- [Enhancement] Support CSS values for defaultSize, maxSize & minSize HOT 1
- onDragging not working HOT 2
- Issue with conditionally rendered Panels HOT 4
- Example for fixing SSR flicker in NextJS page router HOT 7
- How to change minimum size to collapse the panel HOT 4
- Can I use conditional rendering with imperative group panel API? HOT 4
- feature request: typed external storage API HOT 1
- onDragging to much calls HOT 3
- Z Index issues HOT 3
- panel seems to get clipped when dragging up HOT 6
- Resizing panel doesn't set the new resize state until clicking on the resize handle (v2.0.0+) HOT 3
- UseLayoutEffect on PanelResizeHandle.ts (SSR) HOT 2
- Tiny layout shift (SSR) HOT 1
- Drag gets priority over overlapping elements HOT 7
- data-panel-size did not match. Server: "null" Client: number HOT 12
- Error: "Failed to execute 'getComputedStyle' on 'Window'" HOT 3
- [Enhancement] Provide "null" storage to avoid persistence in localstorage HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-resizable-panels.