diff --git a/change/react-native-windows-0b14d2b4-ff2a-4e94-95f7-bc04edf1a1e4.json b/change/react-native-windows-0b14d2b4-ff2a-4e94-95f7-bc04edf1a1e4.json new file mode 100644 index 00000000000..ba2817c6e9c --- /dev/null +++ b/change/react-native-windows-0b14d2b4-ff2a-4e94-95f7-bc04edf1a1e4.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "adding accessibility and UIA support for XAML fabric", + "packageName": "react-native-windows", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp index 6e7b6ac7b1c..8e71d242d13 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp @@ -125,6 +125,27 @@ bool ContentIslandComponentView::focusable() const noexcept { return true; } +facebook::react::Tag ContentIslandComponentView::hitTest( + facebook::react::Point pt, + facebook::react::Point &localPt, + bool ignorePointerEvents) const noexcept { + facebook::react::Point ptLocal{pt.x - m_layoutMetrics.frame.origin.x, pt.y - m_layoutMetrics.frame.origin.y}; + + // Check if the point is within the bounds of this ContentIslandComponentView. + // This ensures that hit tests correctly return this view's tag for UIA purposes, + // even when the actual content (XAML buttons, etc.) is hosted in the ContentIsland. + auto props = viewProps(); + if ((ignorePointerEvents || props->pointerEvents == facebook::react::PointerEventsMode::Auto || + props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) && + ptLocal.x >= 0 && ptLocal.x <= m_layoutMetrics.frame.size.width && ptLocal.y >= 0 && + ptLocal.y <= m_layoutMetrics.frame.size.height) { + localPt = ptLocal; + return Tag(); + } + + return -1; +} + // Helper to convert a FocusNavigationDirection to a FocusNavigationReason. winrt::Microsoft::UI::Input::FocusNavigationReason GetFocusNavigationReason( winrt::Microsoft::ReactNative::FocusNavigationDirection direction) noexcept { diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h index f530baa3400..013ae66f2f0 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h @@ -40,6 +40,9 @@ struct ContentIslandComponentView : ContentIslandComponentViewT