Skip to content

Conversation

@chiaramooney
Copy link
Contributor

@chiaramooney chiaramooney commented Mar 5, 2021

#7220 added functionality to announceForAccessibility which worked for UWP apps. New changes allow for method to work for apps using XAML Islands. Note: apps using XAML Islands must now set/specify an AccessibleXamlRoot in order for announceForAccessibility to work. AccessibleXamlRoots must be able to create an automation peer or need to set AutomationProperties::LandmarkTypeProperty() to 80002.

Resolves #7245

Microsoft Reviewers: Open in CodeFlow

@chiaramooney chiaramooney requested a review from asklar March 5, 2021 20:14
@chiaramooney chiaramooney requested a review from a team as a code owner March 5, 2021 20:14
@ghost ghost added Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) and removed Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) labels Mar 7, 2021
@chiaramooney chiaramooney requested a review from asklar March 8, 2021 21:27
Comment on lines 30 to 34
static void SetAccessibleRoot(IReactPropertyBag properties, XAML_NAMESPACE.XamlRoot xamlRoot);
DOC_STRING("Retrieve XamlRoot for app.")
static XAML_NAMESPACE.XamlRoot GetXamlRoot(IReactPropertyBag properties);
DOC_STRING("Retrieve accessible XamlRoot for app.")
static XAML_NAMESPACE.XamlRoot GetAccessibleRoot(IReactPropertyBag properties);
Copy link
Member

Choose a reason for hiding this comment

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

can you make the type of the root FrameworkElement? it is not necessary for the app to have an accessible xaml root, just a framework element that we can announce on

if (!textBlock) {
return;
if (react::uwp::IsXamlIsland()) {
if (auto xamlroot =
Copy link
Member

Choose a reason for hiding this comment

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

once you change the type of Get/SetAccessibleRoot to FrameworkElement, name this accordingly (accessibleRoot)

if (!element) {
if (auto window = xaml::Window::Current()) {
if (element = window.Content()) {
element.SetValue(xaml::Automation::AutomationProperties::LandmarkTypeProperty(), winrt::box_value(80002));
Copy link
Member

Choose a reason for hiding this comment

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

this is not needed. An app can do this on the frameworkElement they give us if they so choose, but we shouldn't do it for them

Copy link
Member

Choose a reason for hiding this comment

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

Also this code would never execute as it is today, if you're in an island then Window::Current would end up being null in winui 3. It works today against system xaml but that's a bug/behavior that is being fixed in winui3

}

ReactPropertyId<xaml::XamlRoot> AccessibleRootProperty() noexcept {
static ReactPropertyId<xaml::XamlRoot> propId{L"ReactNative.UIManager", L"AccessibleXamlRoot"};
Copy link
Member

Choose a reason for hiding this comment

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

name it AccessibleRoot, or AccessibleRootElement or something liket that

Copy link
Member

@asklar asklar left a comment

Choose a reason for hiding this comment

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

please change the type of accessible root to be frameworkelement as xamlroots are not required here

@ghost ghost added the Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) label Mar 11, 2021
@ghost ghost removed the Needs: Author Feedback The issue/PR needs activity from its author (label drives bot activity) label Mar 12, 2021
DOC_STRING("Set XamlRoot for app. This must be manually provided to the ReactInstanceSettings when using XamlIslands.")
static void SetXamlRoot(IReactPropertyBag properties, XAML_NAMESPACE.XamlRoot xamlRoot);
// This needs to be manually provided to the ReactInstanceSettings when using XamlIslands
DOC_STRING("Set accessible XamlRoot for app. This XamlRoot should be able to create an automation peer. This must be manually provided to the ReactInstanceSettings when using XamlIslands to have access to accessibility methods.")
Copy link
Member

Choose a reason for hiding this comment

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

please update the doc string too (here and below)

@chiaramooney chiaramooney merged commit 2dfb964 into microsoft:master Mar 12, 2021
@chiaramooney chiaramooney deleted the cm-fix-access-announce branch March 12, 2021 16:27
rozele pushed a commit to rozele/react-native-windows that referenced this pull request Oct 6, 2021
Summary:
Cherry picks:
microsoft#5849
microsoft#7220
microsoft#7290

Test Plan: See D29689294 Test Plan

Reviewers: ericroz

Reviewed By: ericroz

Subscribers: eliwhite

Differential Revision: https://phabricator.intern.facebook.com/D30940769

Tasks: T85606613

Signature: 30940769:1631724353:41db1d978132f06502803cfb4df0323f6da84732
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants