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

Handle rapid changes to collapsed prop #233

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jenni-divvito
Copy link

I had an issue while using a collapsible that was to be collapsed while the keyboard was showing. When the device (iPhone X in this case) was rotated, the following series of events unfolds:

  1. KeyboardWillHide event emitted
  2. We pass collapsed: false to the <Collapsible/>
  3. _toggleCollapsed(false) -> _measureContent() starts
  4. KeyboardWillShow event emitted
  5. We pass collapsed: true to the <Collapsible/>
  6. _toggleCollapsed(false) -> _transitionToHeight(0)
  7. measuring finishes
  8. _transitionToHeight(contentHeight) is started due to callback from _measureContent
  9. content now has a height, even though it has collapsed: true prop.

I'm not altogether sure why on iOS react native fires the KeyboardWillHide and KeyboardWillShow events one after the other when the device is rotated, but that seems to be the case.

The attached change makes the behaviour, instead of assuming that after measuring, the content should be shown uncollapsed; that after measuring the content should be shown in whatever state the collapsed property is once measuring is completed. Other than resolving my own issue it should work for other cases where the property changes rapidly.

I had an issue while using a collapsible that was to be collapsed while the keyboard was showing. When the device (iPhone X in this case) was rotated, the following series of events unfolds:
1. `KeyboardWillHide` event emitted
2. We pass `collapsed: false` to the `<Collapsible/>`
3. `_toggleCollapsed(false)` -> `_measureContent()` starts
4. `KeyboardWillShow` event emitted
5. We pass `collapsed: true` to the `<Collapsible/>`
6. `_toggleCollapsed(false)` -> `_transitionToHeight(0)`
7. measuring finishes
8. `_transitionToHeight(contentHeight)` is started due to callback from _measureContent
9. content now has a height, even though it has `collapsed: true` prop.

I'm not altogether sure why on iOS react native fires the KeyboardWillHide and KeyboardWillShow events one after the other when the device is rotated, but that seems to be the case.

The attached change makes the behaviour, instead of assuming that after measuring, the content should be shown uncollapsed; that after measuring the content should be shown in whatever state the collapsed property is once measuring is completed. Other than resolving my own issue it should work for other cases where the property changes rapidly.
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

Successfully merging this pull request may close these issues.

1 participant