Skip to content

Commit 5cc5b14

Browse files
[Fabric] Implementation of accessibilityAccessKey and accessibilityItemType (#14658)
* {Fabric] Implementation of accessibilityAccessKey and accessibilityItemType * Change Files * Updating snapShot
1 parent 5db40de commit 5cc5b14

File tree

14 files changed

+92
-1
lines changed

14 files changed

+92
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Implementation of accessibilityItemType",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Implementation of accessibilityAccessKey",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/@react-native-windows/tester/src/js/examples-win/Accessibility/AccessibilityExampleWindows.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class AccessibilityBaseExample extends React.Component {
2626
accessibilityLabel="A blue box"
2727
accessibilityHint="A hint for the blue box."
2828
accessibilityLevel={1}
29+
accessibilityItemType="comment"
30+
accessibilityAccessKey="accessKey"
2931
accessibilityAnnotation={{
3032
typeID: 'Comment',
3133
typeName: 'Check Comment',

packages/e2e-test-app-fabric/test/__snapshots__/AccessibilityTest.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ exports[`Accessibility Tests Accessibility data for Label and Level 1`] = `
3232
exports[`Accessibility Tests Accessibility data for Label,Level and Hint 1`] = `
3333
{
3434
"Automation Tree": {
35+
"AccessKey": "accessKey",
3536
"AnnotationPattern.Author": "Clint Westwood",
3637
"AnnotationPattern.DateTime": "3/19/2025 1:03 PM",
3738
"AnnotationPattern.TypeId": 60003,
3839
"AnnotationPattern.TypeName": "Check Comment",
3940
"AutomationId": "accessibility-base-view-1",
4041
"ControlType": 50026,
4142
"HelpText": "A hint for the blue box.",
43+
"ItemType": "comment",
4244
"Level": 1,
4345
"LocalizedControlType": "group",
4446
"Name": "A blue box",

packages/e2e-test-app-fabric/test/__snapshots__/snapshotPages.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ exports[`snapshotAllPages Accessibility Windows 1`] = `
88
The following has accessibilityLabel and accessibilityHint:
99
</Text>
1010
<View
11+
accessibilityAccessKey="accessKey"
1112
accessibilityAnnotation={
1213
{
1314
"author": "Clint Westwood",
@@ -17,6 +18,7 @@ exports[`snapshotAllPages Accessibility Windows 1`] = `
1718
}
1819
}
1920
accessibilityHint="A hint for the blue box."
21+
accessibilityItemType="comment"
2022
accessibilityLabel="A blue box"
2123
accessibilityLevel={1}
2224
accessible={true}

packages/e2e-test-app-fabric/windows/RNTesterApp-Fabric/RNTesterApp-Fabric.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
523523
int level = 0;
524524
LiveSetting liveSetting = LiveSetting::Off;
525525
BSTR itemStatus;
526+
BSTR itemType;
527+
BSTR accessKey;
526528

527529
pTarget->get_CurrentAutomationId(&automationId);
528530
pTarget->get_CurrentControlType(&controlType);
@@ -532,6 +534,8 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
532534
pTarget->get_CurrentLocalizedControlType(&localizedControlType);
533535
pTarget->get_CurrentName(&name);
534536
pTarget->get_CurrentItemStatus(&itemStatus);
537+
pTarget->get_CurrentItemType(&itemType);
538+
pTarget->get_CurrentAccessKey(&accessKey);
535539
IUIAutomationElement4 *pTarget4;
536540
HRESULT hr = pTarget->QueryInterface(__uuidof(IUIAutomationElement4), reinterpret_cast<void **>(&pTarget4));
537541
if (SUCCEEDED(hr) && pTarget4) {
@@ -554,6 +558,8 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
554558
InsertIntValueIfNotDefault(result, L"Level", level);
555559
InsertLiveSettingValueIfNotDefault(result, L"LiveSetting", liveSetting);
556560
InsertStringValueIfNotEmpty(result, L"ItemStatus", itemStatus);
561+
InsertStringValueIfNotEmpty(result, L"ItemType", itemType);
562+
InsertStringValueIfNotEmpty(result, L"AccessKey", accessKey);
557563
DumpUIAPatternInfo(pTarget, result);
558564

559565
IUIAutomationElement *pChild;

vnext/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,19 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPropertyValue(PROPERT
576576
pRetVal->lVal = props->accessibilityLevel;
577577
break;
578578
}
579+
case UIA_AccessKeyPropertyId: {
580+
pRetVal->vt = VT_BSTR;
581+
auto accessKey = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityAccessKey.value_or(""));
582+
pRetVal->bstrVal = SysAllocString(accessKey.c_str());
583+
break;
584+
}
585+
case UIA_ItemTypePropertyId: {
586+
pRetVal->vt = VT_BSTR;
587+
auto itemtype = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityItemType.value_or(""));
588+
pRetVal->bstrVal = SysAllocString(itemtype.c_str());
589+
break;
590+
}
579591
}
580-
581592
return hr;
582593
}
583594

vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,18 @@ void ComponentView::updateAccessibilityProps(
807807
winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
808808
EnsureUiaProvider(), UIA_LevelPropertyId, oldViewProps.accessibilityLevel, newViewProps.accessibilityLevel);
809809

810+
winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
811+
EnsureUiaProvider(),
812+
UIA_AccessKeyPropertyId,
813+
oldViewProps.accessibilityAccessKey,
814+
newViewProps.accessibilityAccessKey);
815+
816+
winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
817+
EnsureUiaProvider(),
818+
UIA_ItemTypePropertyId,
819+
oldViewProps.accessibilityItemType,
820+
newViewProps.accessibilityItemType);
821+
810822
if ((oldViewProps.accessibilityState.has_value() && oldViewProps.accessibilityState->selected.has_value()) !=
811823
((newViewProps.accessibilityState.has_value() && newViewProps.accessibilityState->selected.has_value()))) {
812824
auto compProvider =

vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ void UpdateUiaProperty(
180180
spProviderSimple.get(), propId, CComVariant(oldValue.c_str()), CComVariant(newValue.c_str()));
181181
}
182182

183+
void UpdateUiaProperty(
184+
winrt::IInspectable provider,
185+
PROPERTYID propId,
186+
const std::optional<std::string> &oldValue,
187+
const std::optional<std::string> &newValue) noexcept {
188+
std::string oldData = oldValue.value_or("");
189+
std::string newData = newValue.value_or("");
190+
UpdateUiaProperty(provider, propId, oldData, newData);
191+
}
192+
183193
long GetLiveSetting(const std::string &liveRegion) noexcept {
184194
if (liveRegion == "polite") {
185195
return LiveSetting::Polite;

vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ void UpdateUiaProperty(
3131
const std::string &oldValue,
3232
const std::string &newValue) noexcept;
3333

34+
void UpdateUiaProperty(
35+
winrt::IInspectable provider,
36+
PROPERTYID propId,
37+
const std::optional<std::string> &oldValue,
38+
const std::optional<std::string> &newValue) noexcept;
39+
3440
long GetLiveSetting(const std::string &liveRegion) noexcept;
3541

3642
long GetAnnotationTypeId(const std::string &annotationType) noexcept;

0 commit comments

Comments
 (0)