diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm index 9fb3400d90cda5..074b9736c44062 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm @@ -179,7 +179,7 @@ - (NSArray *)accessibilityElements // If the component is not `accessible`, we return an empty array. // We do this because logically all nested components represent the content of the component; // in other words, all nested components individually have no sense without the . - if (!_textView.state || !paragraphProps.accessible) { + if (!_textView.state || !paragraphProps.accessible.value_or(false)) { return [NSArray new]; } diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 777428c3772e5e..53b94469167596 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -344,7 +344,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & // `accessible` if (oldViewProps.accessible != newViewProps.accessible) { - self.accessibilityElement.isAccessibilityElement = newViewProps.accessible; + self.accessibilityElement.isAccessibilityElement = newViewProps.accessible.value_or(false); } // `accessibilityLabel` diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FocusOrderingHelper.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FocusOrderingHelper.cpp index e30b1e2c89a0fd..4ae8233b15e084 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FocusOrderingHelper.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FocusOrderingHelper.cpp @@ -118,7 +118,8 @@ void FocusOrderingHelper::traverseAndUpdateNextFocusableElement( // focused and present in the hierarchy if (currNode->getTraits().check(ShadowNodeTraits::Trait::KeyboardFocusable) || (props != nullptr && - (props->focusable || props->accessible || props->hasTVPreferredFocus))) { + (props->focusable || props->accessible.value_or(false) || + props->hasTVPreferredFocus))) { LayoutMetrics nodeLayoutMetrics = uimanager.getRelativeLayoutMetrics( *currNode, parentShadowNode.get(), {.includeTransform = true}); 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 f6686eb76c8914..bf2950c259b817 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityProps.h @@ -31,7 +31,7 @@ class AccessibilityProps { #pragma mark - Props - bool accessible{false}; + std::optional accessible{std::nullopt}; std::optional accessibilityState{std::nullopt}; std::string accessibilityLabel; std::vector accessibilityOrder{}; diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h b/packages/react-native/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h index 38ac9ea6d05b73..e6c8c2f3a3fa4f 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h @@ -118,6 +118,7 @@ class ConcreteViewShadowNode : public ConcreteShadowNode< BaseShadowNode::orderIndex_ = 0; } + // TODO why is this not needed bool isKeyboardFocusable = HostPlatformViewTraitsInitializer::isKeyboardFocusable(props) || props.accessible; diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp index 19e6f2106e005b..3daa6ea605d334 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp @@ -48,7 +48,7 @@ void ViewShadowNode::initialize() noexcept { bool formsStackingContext = !viewProps.collapsable || viewProps.pointerEvents == PointerEventsMode::None || - !viewProps.nativeId.empty() || viewProps.accessible || + !viewProps.nativeId.empty() || viewProps.accessible.value_or(false) || viewProps.opacity != 1.0 || viewProps.transform != Transform{} || (viewProps.zIndex.has_value() && viewProps.yogaStyle.positionType() != yoga::PositionType::Static) || diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp index e64a92fbc314f8..6b8f6481d04b93 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp @@ -692,7 +692,7 @@ folly::dynamic HostPlatformViewProps::getDiffProps( } if (accessible != oldProps->accessible) { - result["accessible"] = accessible; + result["accessible"] = accessible.value_or(false); } if (getClipsContentToBounds() != oldProps->getClipsContentToBounds()) {