From 8e45ff4080cbc38f96711aa668d80bb69bfdff14 Mon Sep 17 00:00:00 2001 From: Agne Lukoseviciute Date: Tue, 31 Aug 2021 08:50:02 -0700 Subject: [PATCH 1/3] default heading level and localizedcontroltype --- .../Views/TextViewManager.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp b/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp index e49b8860e3c..ec541c5c2b3 100644 --- a/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp +++ b/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp @@ -288,6 +288,22 @@ bool TextViewManager::UpdateProperty( node->m_backgroundColor = OptionalColorFrom(propertyValue); node->RecalculateTextHighlighters(); } + } else if (propertyName == "accessibilityRole") { + if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { + const std::string &role = propertyValue.AsString(); + auto value = asHstring(propertyValue); + auto boxedValue = winrt::Windows::Foundation::PropertyValue::CreateString(value); + + textBlock.SetValue(winrt::AutomationProperties::LocalizedControlTypeProperty(), boxedValue); + if (role == "header") { + xaml::Automation::AutomationProperties::SetHeadingLevel( + textBlock, winrt::Peers::AutomationHeadingLevel::Level2); + } else { + textBlock.ClearValue(winrt::AutomationProperties::HeadingLevelProperty()); + } + } else if (propertyValue.IsNull()) { + textBlock.ClearValue(winrt::AutomationProperties::LocalizedControlTypeProperty()); + } } else { return Super::UpdateProperty(nodeToUpdate, propertyName, propertyValue); } From cd7898786df5eb13b80fb1c769182c477ca1d985 Mon Sep 17 00:00:00 2001 From: Agne Lukoseviciute Date: Tue, 31 Aug 2021 09:42:18 -0700 Subject: [PATCH 2/3] Change files --- ...ative-windows-a8b5bad4-4783-4c5f-a6f4-c227c9b6c8d9.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-a8b5bad4-4783-4c5f-a6f4-c227c9b6c8d9.json diff --git a/change/react-native-windows-a8b5bad4-4783-4c5f-a6f4-c227c9b6c8d9.json b/change/react-native-windows-a8b5bad4-4783-4c5f-a6f4-c227c9b6c8d9.json new file mode 100644 index 00000000000..01eb4e990fc --- /dev/null +++ b/change/react-native-windows-a8b5bad4-4783-4c5f-a6f4-c227c9b6c8d9.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "add accessibility UIA headings", + "packageName": "react-native-windows", + "email": "agnel@microsoft.com", + "dependentChangeType": "patch" +} From 7be366647ffe02cc0d110f8d1bbbb02d6eefebdb Mon Sep 17 00:00:00 2001 From: Agne Lukoseviciute Date: Tue, 31 Aug 2021 12:33:00 -0500 Subject: [PATCH 3/3] Update vnext/Microsoft.ReactNative/Views/TextViewManager.cpp Co-authored-by: Jon Thysell --- vnext/Microsoft.ReactNative/Views/TextViewManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp b/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp index ec541c5c2b3..e8ae7c581e9 100644 --- a/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp +++ b/vnext/Microsoft.ReactNative/Views/TextViewManager.cpp @@ -303,6 +303,7 @@ bool TextViewManager::UpdateProperty( } } else if (propertyValue.IsNull()) { textBlock.ClearValue(winrt::AutomationProperties::LocalizedControlTypeProperty()); + textBlock.ClearValue(winrt::AutomationProperties::HeadingLevelProperty()); } } else { return Super::UpdateProperty(nodeToUpdate, propertyName, propertyValue);