b-zurg/react-collapse-pane

Inaccurate width calculation for panes on container resize

godsamit opened this issue · 0 comments

When I collapse, if I don't have an onCollapse callback, the panel is being correctly collapsed to the size specified in collapseOptions.collapseSize. However, if I add the onCollapse callback, it's now being incorrectly collapsed.

I tried to log the sizes array passed to onCollapse. sizes[collapsedIdx] it's not the collapseSize, and it's not consistent either. Did it take the value from before the animation is finished?

For my specific case, I tried checking if sizes[collapsedIdx] is null. If it's not, I'm manually constructing a new array for the state. However I think this causes an infinite loop that I haven't been able to figure out where, and everything freezes.

---- Edit:

With further debugging, I think it's the width calculation returned incorrect result.
After some container resize, the flex-basis of all children doesn't add up to the container size.

One fix is to make the collapsed children has a flex-grow of 0. I have created a PR #80