From 010e0010a38e111df110584ebacaabe210c3f137 Mon Sep 17 00:00:00 2001 From: Jakub Grzywacz Date: Mon, 12 Aug 2024 10:36:57 -0700 Subject: [PATCH] Make setPointerEvents public on ReactViewGroup.java (#45975) Summary: I maintain the `react-native-svg` library, where our elements extend `ReactViewGroup`. Currently, `ReactViewGroup` only exposes the getter for `mPointerEvents` publicly, so we cannot set it. To properly handle `pointerEvents`, we would have to duplicate all methods related to `mPointerEvents`, which results in maintaining a separate state. This duplication can lead to desynchronization between the state in our class and the state in the superclass. PR with a workaround that we can avoid with this change https://github.com/software-mansion/react-native-svg/pull/2395 ## Changelog: [ANDROID] [CHANGED] - make `setPointerEvents` public Pull Request resolved: https://github.com/facebook/react-native/pull/45975 Test Plan: This change was tested manually by making the field public, allowing dependent classes to override or reference it. Reviewed By: cortinico Differential Revision: D61124293 Pulled By: javache fbshipit-source-id: 389d0a670375a8a68c975294f98c33c28ef41ffe --- packages/react-native/ReactAndroid/api/ReactAndroid.api | 1 + .../main/java/com/facebook/react/views/view/ReactViewGroup.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 62fa18eb249..fb02f33c4eb 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -8247,6 +8247,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro public fun setOpacityIfPossible (F)V public fun setOverflow (Ljava/lang/String;)V public fun setOverflowInset (IIII)V + public fun setPointerEvents (Lcom/facebook/react/uimanager/PointerEvents;)V public fun setRemoveClippedSubviews (Z)V public fun setTranslucentBackgroundDrawable (Landroid/graphics/drawable/Drawable;)V public fun updateClippingRect ()V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index edaba93365d..66f666a261e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -673,7 +673,7 @@ public class ReactViewGroup extends ViewGroup // to it's children. } - /*package*/ void setPointerEvents(PointerEvents pointerEvents) { + public void setPointerEvents(PointerEvents pointerEvents) { mPointerEvents = pointerEvents; }