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 15, 2024
1 parent e2b661c commit ec2a291
Show file tree
Hide file tree
Showing 8 changed files with 33 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,7 +477,7 @@ class AccessibilityExample extends React.Component<
{name: 'expand', label: 'expand'},
{name: 'collapse', label: 'collapse'},
]}
accessibilityState={{expanded: this.state.expanded}}
accessibilityState={{expanded: this.state.expanded, busy: true}}
accessibilityPosInSet={1}
accessibilitySetSize={1}
accessibilityLiveRegion='polite'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,8 @@ exports[`View Tests Views can have customized accessibility 1`] = `
"ExpandCollapsePattern.ExpandCollapseState": "Expanded",
"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 @@ -83774,6 +83774,7 @@ exports[`snapshotAllPages View 20`] = `
accessibilitySetSize={1}
accessibilityState={
{
"busy": true,
"expanded": true,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,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 @@ -413,6 +414,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 @@ -432,6 +434,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 @@ -447,6 +450,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,7 @@ 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,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 @@ -1309,6 +1309,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 ec2a291

Please sign in to comment.