Skip to content

Commit

Permalink
Add Support for AccessibilityState:Busy (microsoft#13952)
Browse files Browse the repository at this point in the history
* Support AccessibilityState: Busy

* Change files

* Add Testing

* Update Snapshots

* Update for Leak
  • Loading branch information
chiaramooney authored and acoates-ms committed Oct 16, 2024
1 parent bb1112c commit 9de1141
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Support AccessibilityState: Busy",
"packageName": "react-native-windows",
"email": "34109996+chiaramooney@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ class AccessibilityExample extends React.Component<
{name: 'copy', label: 'copy'},
{name: 'paste', label: 'paste'},
]}
accessibilityState={{expanded: this.state.expanded, busy: true}}
accessibilityPosInSet={1}
accessibilitySetSize={1}
accessibilityLiveRegion='polite'
testID="accessibility"
accessible
focusable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,8 @@ exports[`View Tests Views can have customized accessibility 1`] = `
"ControlType": 50000,
"HelpText": "Accessibility Hint",
"IsKeyboardFocusable": true,
"ItemStatus": "Busy",
"LiveSetting": "Polite",
"LocalizedControlType": "button",
"Name": "A View with accessibility values",
"__Children": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67829,7 +67829,18 @@ exports[`snapshotAllPages View 21`] = `
accessibilityHint="Accessibility Hint"
accessibilityLabel="A View with accessibility values"
accessibilityRole="button"
accessibilityValue={0}
accessibilitySetSize={1}
accessibilityState={
{
"busy": true,
"expanded": true,
}
}
accessibilityValue={
{
"now": 0,
}
}
accessible={true}
focusable={true}
onAccessibilityAction={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
int positionInSet = 0;
int sizeOfSet = 0;
LiveSetting liveSetting = LiveSetting::Off;
BSTR itemStatus;

pTarget->get_CurrentAutomationId(&automationId);
pTarget->get_CurrentControlType(&controlType);
Expand All @@ -387,6 +388,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
pTarget->get_CurrentIsKeyboardFocusable(&isKeyboardFocusable);
pTarget->get_CurrentLocalizedControlType(&localizedControlType);
pTarget->get_CurrentName(&name);
pTarget->get_CurrentItemStatus(&itemStatus);
IUIAutomationElement4 *pTarget4;
HRESULT hr = pTarget->QueryInterface(__uuidof(IUIAutomationElement4), reinterpret_cast<void **>(&pTarget4));
if (SUCCEEDED(hr) && pTarget4) {
Expand All @@ -406,6 +408,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
InsertIntValueIfNotDefault(result, L"PositionInSet", positionInSet);
InsertIntValueIfNotDefault(result, L"SizeofSet", sizeOfSet);
InsertLiveSettingValueIfNotDefault(result, L"LiveSetting", liveSetting);
InsertStringValueIfNotEmpty(result, L"ItemStatus", itemStatus);
DumpUIAPatternInfo(pTarget, result);

IUIAutomationElement *pChild;
Expand All @@ -421,6 +424,11 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
if (children.Size() > 0) {
result.Insert(L"__Children", children);
}
::SysFreeString(automationId);
::SysFreeString(helpText);
::SysFreeString(localizedControlType);
::SysFreeString(name);
::SysFreeString(itemStatus);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ exports[`ViewTests Views can have a custom nativeID 1`] = `
exports[`ViewTests Views can have accessibility customization 1`] = `
{
"AccessibilityRole": "Button",
"AccessibilityStateBusy": true,
"AccessibilityStateExpanded": true,
"AutomationId": "accessibility",
"Background": null,
"BorderBrush": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPropertyValue(PROPERT
pRetVal->lVal = GetLiveSetting(props->accessibilityLiveRegion);
break;
}
case UIA_ItemStatusPropertyId: {
pRetVal->vt = VT_BSTR;
pRetVal->bstrVal = (props->accessibilityState.has_value() && props->accessibilityState->busy)
? SysAllocString(L"Busy")
: SysAllocString(L"");
break;
}
}

return hr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,12 @@ void ComponentView::updateAccessibilityProps(
!(oldViewProps.accessibilityState && oldViewProps.accessibilityState->disabled),
!(newViewProps.accessibilityState && newViewProps.accessibilityState->disabled));

winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
m_uiaProvider,
UIA_IsEnabledPropertyId,
!(oldViewProps.accessibilityState && oldViewProps.accessibilityState->busy),
!(newViewProps.accessibilityState && newViewProps.accessibilityState->busy));

winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
m_uiaProvider, UIA_ControlTypePropertyId, oldViewProps.accessibilityRole, newViewProps.accessibilityRole);

Expand Down

0 comments on commit 9de1141

Please sign in to comment.