mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add conditional return in handleRemoveView (#43389)
Summary: I was recently working on an [issue](https://github.com/software-mansion/react-native-reanimated/issues/5715) in Reanimated where z-index of some views was broken after a Layout Animation was used. The issue was that in some cases we were calling the `removeView` function on a already removed view. On plain Android this wouldn't be an issue, since the `removeView` function ignores such calls. Unfortunately, the `ReactViewGroup.java` implementation maintains a counter of views with user defined z-index. This counter is decremented whenever a call to `removeView` is made, even if the view is not a child of this `ViewGroup`. This PR adds an additional check in the `handleRemoveView` function to unify the `removeView` behavior between Android and react-native. ## Changelog: [ANDROID] [CHANGED] - Changed the `handleRemoveView` function in `ReactViewGroup.java` to ignore calls for `Views` that are not children of this `ViewGroup` Pull Request resolved: https://github.com/facebook/react-native/pull/43389 Test Plan: I tested if the `rn-tester` app behaves correctly after those changes. Reviewed By: NickGerleman Differential Revision: D54874780 Pulled By: javache fbshipit-source-id: f1a34947419ef6106ee73b196ae99b7f8c2f7a77
This commit is contained in:
committed by
Facebook GitHub Bot
parent
47a3f52007
commit
0d7a92b551
+3
@@ -519,6 +519,9 @@ public class ReactViewGroup extends ViewGroup
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
if (!customDrawOrderDisabled()) {
|
||||
if (indexOfChild(view) == -1) {
|
||||
return;
|
||||
}
|
||||
getDrawingOrderHelper().handleRemoveView(view);
|
||||
setChildrenDrawingOrderEnabled(getDrawingOrderHelper().shouldEnableCustomDrawingOrder());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user