Skip to content
Merged
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};

// 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();
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer const auto props = viewProps().

When declaring a variable in C++, almost always default to const T var = value. Drop const only if you know you're going to write to it. Why? Refer What is “const correctness”?.

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly named variables should usually be avoided. They are hard to understand for readers. Consider renaming ptLocal to something else.

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