From e13ee7a3d05fb64ddd5afb6ea1a6927cafedd3d4 Mon Sep 17 00:00:00 2001 From: Jorge Cabiedes Acosta Date: Mon, 16 Jun 2025 10:22:05 -0700 Subject: [PATCH] Fix accessibilityRespondsToUserInteraction not setting on first render (#51986) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51986 "{}" defaults to false on C++ but the prop is not initialized which means that if accessibilityEnablesUserInteraction is set to false it will not be applied on first render. setting the default to true fixes that issue Changelog: [Internal] Reviewed By: joevilches Differential Revision: D76532158 fbshipit-source-id: 51cba8b89eb239e01db985d412dd2b19e482f068 --- .../react/renderer/components/view/AccessibilityProps.cpp | 2 +- .../react/renderer/components/view/AccessibilityProps.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp index 495b2aa1861..4b0294108a7 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp @@ -162,7 +162,7 @@ AccessibilityProps::AccessibilityProps( rawProps, "accessibilityRespondsToUserInteraction", sourceProps.accessibilityRespondsToUserInteraction, - {})), + true)), onAccessibilityTap( ReactNativeFeatureFlags::enableCppPropsIteratorSetter() ? sourceProps.onAccessibilityTap diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.h b/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.h index f6686eb76c8..7c798c1cf3e 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.h @@ -49,7 +49,10 @@ class AccessibilityProps { bool accessibilityViewIsModal{false}; bool accessibilityElementsHidden{false}; bool accessibilityIgnoresInvertColors{false}; - bool accessibilityRespondsToUserInteraction{}; + // This prop is enabled by default on iOS, we need to match this on + // C++ because if not, it will default to false before render which prevents + // the view from being updated with the correct value. + bool accessibilityRespondsToUserInteraction{true}; bool onAccessibilityTap{}; bool onAccessibilityMagicTap{}; bool onAccessibilityEscape{};