Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "adding accessibility and UIA support for XAML fabric",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible there's a scale or other transform that needs to be applied?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a valid concern. The hitTest method should consider the scale/transform. Looking at the ViewComponentView::hitTest implementation, it correctly handles the origin offset


// 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function ("hitTest") only called for UIA, or can it be called for other reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hitTest is called for multiple purposes, not just UIA:

  1. UIA/Accessibility via RootComponentView::UiaProviderFromPoint
  2. Pointer/Touch Events via CompositionEventHandler
  3. Focus Navigation:

// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct ContentIslandComponentView : ContentIslandComponentViewT<ContentIslandCom

bool focusable() const noexcept override;

facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
const noexcept override;

winrt::Windows::Foundation::IInspectable EnsureUiaProvider() noexcept override;

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