Skip to content
Merged
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
Expand Up @@ -18,6 +18,7 @@
#include <winrt/Microsoft.ReactNative.h>

#include <CppWinRTIncludes.h>
#include <UI.Xaml.Automation.h>
#include <UI.Xaml.Controls.h>
#include <UI.Xaml.Hosting.h>
#include <winrt/Windows.Foundation.Collections.h>
Expand Down Expand Up @@ -110,6 +111,11 @@ struct WindowData {
auto rootElement = m_desktopWindowXamlSource.Content().as<controls::Panel>();
winrt::Microsoft::ReactNative::XamlUIService::SetXamlRoot(
host.InstanceSettings().Properties(), rootElement.XamlRoot());
winrt::Microsoft::ReactNative::XamlUIService::SetAccessibleRoot(
host.InstanceSettings().Properties(), rootElement);
rootElement.SetValue(
winrt::Windows::UI::Xaml::Automation::AutomationProperties::LandmarkTypeProperty(),
winrt::box_value(80002));
Comment on lines +116 to +118
Copy link
Member

Choose a reason for hiding this comment

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

this should not be needed if you do the first API call. This is a fallback in cases where you don't have an accessible root. Narrator may not behave "as well" when setting landmark type this way, so prefer using just the xaml root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I verified this is needed (or maybe I'm missing something about your comment?). If I delete this then Narrator doesn't announce anything when trying the AccessibilityInfo example in playground-win32 RNTester. This also aligns with what's mentioned in #7290:

AccessibleXamlRoots must be able to create an automation peer or need to set AutomationProperties::LandmarkTypeProperty() to 80002.

Copy link
Member

Choose a reason for hiding this comment

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

@lyahdav what is the concrete type of the thing that you pass to SetAccessibleXamlRoot ? it needs to be one of the FrameworkElement derived types that is associated with the list of derived types in this page:

https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer?view=winrt-20348

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per https://github.com/microsoft/react-native-windows/blob/main/packages/playground/windows/playground-win32/Playground-Win32.cpp#L366 this is a Grid. From what you linked there is no GridAutomationPeer. At the point we SetAccessibleRoot we only have that control available. So what makes sense, to set LandmarkTypeProperty or to create some other dummy control? LandmarkTypeProperty seems cleaner.


#ifdef USE_WINUI3
const auto islandWindow = (uint64_t)GetXamlIslandHwnd(m_desktopWindowXamlSource);
Expand Down