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

collapsedSize with variable breaks onCollapse function #237

Closed
IsisHerrero opened this issue Dec 21, 2023 · 2 comments
Closed

collapsedSize with variable breaks onCollapse function #237

IsisHerrero opened this issue Dec 21, 2023 · 2 comments

Comments

@IsisHerrero
Copy link

Hi,

I have been developing a view with 3 panels, all of them to collapse at the same minSize and to call a function onCollapse and another function onExpand. I have added the collapsedSize, so that the collapsed panel will have a specific width (48px). This specific width is calculated in a useEffect on render and set to a variable that then I pass to the panels.

When I resize a panel, the panel's width gets set to the collapsedSize, but the onCollapse function does not get called, I have tested setting the collapsedSize as an actual number (for example, collapsedSize={5}) and the onCollapse function works. But it doesn't when the collapsedSize is set through the variable (collapsedSize={collapsedSizeVariable}).

The collapsedSizeVariable gets calculated in the following way:

useEffect(() => {
   const windowWidth = window.innerWidth;
   if (windowWidth) {
     // collapsedSize to be 48px
     setCollapsedSizeVariable((48 * 100) / windowWidth);
   }
}, []);

Any advice about how to get around this issue?

Br

@bvaughn
Copy link
Owner

bvaughn commented Dec 21, 2023

Please share a full repro of this issue and I will take a look. Preferably a Code Sandbox or something that I can just click and run.

@IsisHerrero
Copy link
Author

I was preparing the a simplified repo for sharing with you and the error did not happen. I started my component anew all the way to its most complex version and I have been able to fix the issue somehow; still need to investigate where the error was coming from.
But for sure it was not a problem with your library! Thanks for your attention!

@bvaughn bvaughn closed this as completed Dec 22, 2023
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

No branches or pull requests

2 participants