Fix android layout animation z-index bug #5769
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the bug that was causing z-index to behave incorrectly on Android after a layout animation was triggered. The issue was that sometimes our layout animation implementation was causing
removeView
to be called more than once for the same view. This is not a problem on plain Android, since there is a conditional check there for removal. However, react-native's implementation ofReactViewGroup
does not check if the view is a part of thisViewGroup
when handling removal.The handler code decreases the counter, that maintains the number of views that have 'z-index' defined by the user. Calling
removeView
too many times causes the counter to go into negative numbers, causing react to disable custom z-index order, even when there are views with user defined z-index.We decided to add an additional check when calling the
removeView
function inAnimationsManager.java
. There is a possibility we could remove it altogether, but as of now this is not certain and requires further investigation.closes #5715
Test plan
Check if the repro from #5715 works properly