Skip to content

Commit 387c058

Browse files
protikbiswas100Protik Biswas
andauthored
Accessibility and UIA Support for XAML Fabric implementation (#15466)
* accessibility and UIA support * adding lint and formatting fix * adding accessibility and UIA support for XAML fabric * Change files --------- Co-authored-by: Protik Biswas <protikbiswas100@microsoft.com>
1 parent f2784a2 commit 387c058

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "adding accessibility and UIA support for XAML fabric",
4+
"packageName": "react-native-windows",
5+
"email": "protikbiswas100@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ bool ContentIslandComponentView::focusable() const noexcept {
125125
return true;
126126
}
127127

128+
facebook::react::Tag ContentIslandComponentView::hitTest(
129+
facebook::react::Point pt,
130+
facebook::react::Point &localPt,
131+
bool ignorePointerEvents) const noexcept {
132+
facebook::react::Point ptLocal{pt.x - m_layoutMetrics.frame.origin.x, pt.y - m_layoutMetrics.frame.origin.y};
133+
134+
// Check if the point is within the bounds of this ContentIslandComponentView.
135+
// This ensures that hit tests correctly return this view's tag for UIA purposes,
136+
// even when the actual content (XAML buttons, etc.) is hosted in the ContentIsland.
137+
auto props = viewProps();
138+
if ((ignorePointerEvents || props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
139+
props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
140+
ptLocal.x >= 0 && ptLocal.x <= m_layoutMetrics.frame.size.width && ptLocal.y >= 0 &&
141+
ptLocal.y <= m_layoutMetrics.frame.size.height) {
142+
localPt = ptLocal;
143+
return Tag();
144+
}
145+
146+
return -1;
147+
}
148+
128149
// Helper to convert a FocusNavigationDirection to a FocusNavigationReason.
129150
winrt::Microsoft::UI::Input::FocusNavigationReason GetFocusNavigationReason(
130151
winrt::Microsoft::ReactNative::FocusNavigationDirection direction) noexcept {

vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct ContentIslandComponentView : ContentIslandComponentViewT<ContentIslandCom
4040

4141
bool focusable() const noexcept override;
4242

43+
facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
44+
const noexcept override;
45+
4346
winrt::Windows::Foundation::IInspectable EnsureUiaProvider() noexcept override;
4447

4548
void onGotFocus(const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs &args) noexcept override;

0 commit comments

Comments
 (0)