-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Flickering slider saveId bug #48
Comments
If you figure out the cause, or a repro, let me know. |
From: #47 (comment)
I wasn't sure what you meant with min/max external Would you be willing to explain more of how you'd go about achieving min/max limits? |
I suppose I triggered the bug previously with setting |
Ah, right. I don't think I'd consider that a bug in this library (or something I'd try to fix). It's just kind of an invalid configuration. |
If you want to set min/max sizes in pixels and you control the overall width and height of the panel group, then you can do the conversion to whatever the min/max percentage would be. In other words, if you wanted to make sure a panel couldn't shrink below 100px wide, and you know the panel group was 1,000 pixels wide, then you'd need to set |
Here is an example of what I mean: const MIN_SIZE_IN_PIXELS = 100;
const [minSize, setMinSize] = useState(10);
useLayoutEffect(() => {
const panelGroup = document.querySelector('[data-panel-group-id="group"]');
const resizeHandles = document.querySelectorAll(
"[data-panel-resize-handle-id]"
);
const observer = new ResizeObserver(() => {
let height = panelGroup.offsetHeight;
resizeHandles.forEach((resizeHandle) => {
height -= resizeHandle.offsetHeight;
});
// Minimum size in pixels is a percentage of the PanelGroup's height,
// less the (fixed) height of the resize handles.
setMinSize((MIN_SIZE_IN_PIXELS / height) * 100);
});
observer.observe(panelGroup);
resizeHandles.forEach((resizeHandle) => {
observer.observe(resizeHandle);
});
return () => {
observer.disconnect();
};
}, []); |
If the available height is ever too small to actually allow that scenario to work– you can decide what to do, but I don't think there's anything |
I'm going to close this issue because I think it's probably caused by an invalid CSS properties situation but if you see it again let me know and we'll re-open! |
Yup - definitely seemed like a invalid configuration. I just tried You were quick with your solution - I was thinking something more along the lines of keeping the window
Thank you for your assistance. I'll give it a try and see what I come up with :) |
Yup! 🙇🏼 Good luck! |
The flickering: https://codesandbox.io/s/react-resizable-panels-forked-r68rvr?file=/src/App.js
I've just spent over an hour trying to pinpoint why my sliders were flickering.
Long story short, I had the slider state saved in the local storage with the following content:
Deleting the local storage entry fixed my problem.
I don't know how it became broken - I worked off of the codesandbox example so occasionally I had three panels, maybe 4 at most. I'm not sure exactly what the JSON means, but I'm dropping the content of it in here hoping someone will understand what happened, and will help avoid the bug from occurring again. (Not sure whether it's exclusive to development or can also occur in production)
The text was updated successfully, but these errors were encountered: