From 9d11dcd3b06641dc8780043067d6d4fbfcac71d1 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Thu, 15 May 2025 10:36:14 -0700 Subject: [PATCH] make removeView open in ViewGroupManager (#51322) Summary: After conversion to Kotlin we could no longer override the removeView function since it is no longer open. The rest of this class can be overridden as before, but since functions are final by default this doesn't work for the new `removeView` function. Expo is overriding the `removeView` functions in `GroupViewManagerWrapper.kt` (a lot of other ViewManager methods are also overridden here, but the `removeView` is introduced in `ViewGroupManager` and needs to be open as well. `GroupViewManagerWrapper.kt` is a replacement view manager that adds support for a delegate that will receive callbacks whenever one of the methods in the view manager are called. This commit fixes this by making the removeView function explicitly open. ## Changelog: [ANDROID] [FIXED] - Made function `removeView` open in Kotlin class Pull Request resolved: https://github.com/facebook/react-native/pull/51322 Test Plan: Verify that Expo can build against this class. Reviewed By: javache Differential Revision: D74807744 Pulled By: cortinico fbshipit-source-id: 55f4b9deccb7d82ceb78be1d56c2b99a6f7e3ce9 --- packages/react-native/ReactAndroid/api/ReactAndroid.api | 2 +- .../java/com/facebook/react/uimanager/ViewGroupManager.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 90f629a40b6..3a50bd2e0a3 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -4595,7 +4595,7 @@ public abstract class com/facebook/react/uimanager/ViewGroupManager : com/facebo public fun getShadowNodeClass ()Ljava/lang/Class; public static final fun getViewZIndex (Landroid/view/View;)Ljava/lang/Integer; public fun needsCustomLayoutForChildren ()Z - public final fun removeView (Landroid/view/ViewGroup;Landroid/view/View;)V + public fun removeView (Landroid/view/ViewGroup;Landroid/view/View;)V public synthetic fun removeViewAt (Landroid/view/View;I)V public fun removeViewAt (Landroid/view/ViewGroup;I)V public static final fun setViewZIndex (Landroid/view/View;I)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt index 0156a7745a7..ebbdbeb598a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt @@ -49,7 +49,12 @@ constructor(reactContext: ReactApplicationContext? = null) : parent.removeViewAt(index) } - public fun removeView(parent: T, view: View) { + /** + * Expo overrides this function GroupViewManagerWrapper.kt`, which is a replacement view manager + * adding support for delegates receiving callbacks whenever one of the methods in the view + * manager are called. + */ + public open fun removeView(parent: T, view: View) { UiThreadUtil.assertOnUiThread() for (i in 0 until getChildCount(parent)) {