Comments (7)
☕️☕️☕️❤️
from react-resizable-panels.
That sandbox link does not work.
from react-resizable-panels.
Sorry forgot to make it public, should be accessible now.
from react-resizable-panels.
Got it. Thank you. This is a bug, for sure.
I think the behavior is due to first panel's configuration:
<Panel
defaultSize={4}
collapsedSize={4}
collapsible={true}
minSize={15}
maxSize={20}
>
Here is how this library works, at a high level. First, the constraints:
- Resizing one panel always impacts other panels. (In other words, you can't make one panel so big that it causes another panel to shrink below its minimum size.)
- Once you've dragged a resize handle past the min/max size of the panel you're resizing, other panels begin to grow/shrink. (I think this feels more intuitive.) For example, notice how dragging the first resize handle resizes the 3rd panel as well:
- If you reverse drag direction, any resized panels should return toward their original sizes (aka the same resize in reverse)
The above points can be seen with this example group in the video below:
<PanelGroup direction="horizontal">
<Panel defaultSize={30} minSize={20}>
left
</Panel>
<PanelResizeHandle />
<Panel minSize={30}>
middle
</Panel>
<PanelResizeHandle />
<Panel defaultSize={30} minSize={20}>
right
</Panel>
</PanelGroup>
Kapture.2024-03-02.at.08.16.47.mp4
Okay, so how is the above behavior implemented (particularly the 3rd bullet):
- When a drag starts, this library stores the starting coordinates and group layouts
- As the cursor moves, the delta is (re)applied to the starting layout. (This has the benefit of "rewinding" in the exact same way if you reverse the drag.)
- If a drag delta can't be applied to the group because of min/max constraints (aka if the new sizes don't add up to 100%) the drag is rejected and no change is applied
The third bullet above is what's causing the issue you've reported. There is a certain range of drag that produces an invalid layout because of the first panel's collapsed and minimum size constraints. (Basically that panel stays collapsed until it is greater than ~9.5% width, the mid point between its collapsed size of 4% and its minimum size of 15%.)
I think the problem is that the invalid layout at that delta causes the group to fall back to the original layout (rather than the most recent valid layout). That's kind of an oversight on my part. Having this repro should be enough to help me track it down.
In case it's easier to see this by looking at actual code, I recorded a Replay of this (3ae6f833-4e3b-4ad6-b10b-8392b85b4bb2) with comments showing what I explained above.
from react-resizable-panels.
I think I've fixed it, but I need to do some more testing (at least write some regression tests)
Kapture.2024-03-02.at.08.43.05.mp4
from react-resizable-panels.
Fixed in #312 and published as 2.0.12
❤️ → ☕ givebrian.coffee
from react-resizable-panels.
Thanks!🙏
from react-resizable-panels.
Related Issues (20)
- 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
- Assertion Failed on conditionally rendered panels with size constraints HOT 7
- [FEAT] Snap Points: Predefined sizes to get snapped to. HOT 1
- Panel becomes unresizable after a certain vertical position in the page HOT 4
- PanelGroup different height with collapsed children HOT 2
- Global cursor style persists if PanelResizeHandle is disabled while dragging HOT 6
- Is there a way to animate collapse() and expand()? HOT 5
- High Memory Usage and UI Freezing When Resizing Panels 😢 HOT 5
- Feature Request: Greedy Panels HOT 14
- Feature Request: Panel Size Memory HOT 3
- Programmably resize panel HOT 1
- pass `ref = useRef<ImperativePanelHandle>(null);` down the component three HOT 4
- Flickering when using three panels HOT 1
- Unstable panel widths with more than three panels HOT 14
- Feature Request: Size stepping HOT 1
- .isCollapsed() seems very unreliable? HOT 7
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.