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

fix: measure content height on layout change #147

Merged
merged 2 commits into from
Apr 15, 2018
Merged

fix: measure content height on layout change #147

merged 2 commits into from
Apr 15, 2018

Conversation

eduardomoroni
Copy link
Contributor

When you were with collapsible opened (state.collapsed = false) and children changes it's height, Collapsible component was breaking the layout.

When you were with collapsible opened (`state.collapsed = false`) and children changes it's height, Collapsible component was breaking the layout.
@iRoachie iRoachie changed the base branch from master to next February 14, 2018 11:36
@iRoachie
Copy link
Collaborator

Hey I think your PR looks good, can you just create a small example repo so I could see this in action? A before and after?

@eduardomoroni
Copy link
Contributor Author

Hey @iRoachie, could I sent you a GIF? Reproduce this error might take a while and I don't have too much time lately :/

@iRoachie
Copy link
Collaborator

Sure that works, just make sure in the gif you can see both:

  • the problem (before your PR)
  • the solution (after your PR)

@ayushinigam
Copy link

Hi @iRoachie,
I can confirm that the PR works. It fixes the issue of re measuring the height on layout change.
It would be really helpful if you could merge it.

Thanks

@eduardomoroni
Copy link
Contributor Author

Sorry guys, didn't have cycles to create a GIF or an example showing this working, could help us with that @ayushinigam?

@iRoachie
Copy link
Collaborator

@ayushinigam I would love to merge this PR if it fixes a problem. I just need to be sure what it's supposed to fix, and if it accurately does that. This is the reasoning behind asking for an example app maybe to be made so that the changes can be observed

@iRoachie iRoachie merged commit 117f7a1 into oblador:next Apr 15, 2018
iRoachie added a commit that referenced this pull request Apr 25, 2018
@oliverdolgener
Copy link

oliverdolgener commented Oct 4, 2018

@iRoachie why was this feature reverted? I have the same problem: I am using the Collapsible with a FlatList as child that gets updated dynamically while the collapsible is not collapsed resulting in a wrong height calculation. The added items are shown only when collapsing and reopening the list.

@iRoachie
Copy link
Collaborator

iRoachie commented Oct 4, 2018

@oliverdolgener because of #168

@oliverdolgener
Copy link

@iRoachie oh that's too bad! But I understand the problems this caused. Do you have an idea for my problem? Is there a function I could call upon receiving new data to update the collapsible height?

@oliverdolgener
Copy link

@iRoachie I solved the problem by replacing my FlatList with a simple map() function. Not the most beautiful solution but it works!

@papigers
Copy link

For those who still have this problem, I've found a little hack that should be better than replacing FlatList with map() (especially for long lists).
Set the initial value for collapsed to be false, and use componentDidMount/useEffect/useFocusEffect (=react-navigation) to set the collapsed value to be true on mount or screen focus.
The only downside (which I don't really consider as a downside but still) is that the user sees the initial uncollapse animation.

@wmonecke
Copy link

This PR introduces flickering. Anyone else experiencing the same?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants