Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "[Fabric] Implementation of accessibilityDescription",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AccessibilityBaseExample extends React.Component {
accessibilityLevel={1}
accessibilityItemType="comment"
accessibilityAccessKey="accessKey"
accessibilityDescription="Sample Description"
accessibilityAnnotation={{
typeID: 'Comment',
typeName: 'Check Comment',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ exports[`Accessibility Tests Accessibility data for Label,Level and Hint 1`] = `
"AnnotationPattern.TypeName": "Check Comment",
"AutomationId": "accessibility-base-view-1",
"ControlType": 50026,
"Description": "Sample Description",
"HelpText": "A hint for the blue box.",
"ItemType": "comment",
"Level": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports[`snapshotAllPages Accessibility Windows 1`] = `
"typeName": "Check Comment",
}
}
accessibilityDescription="Sample Description"
accessibilityHint="A hint for the blue box."
accessibilityItemType="comment"
accessibilityLabel="A blue box"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
BSTR itemStatus;
BSTR itemType;
BSTR accessKey;
BSTR description = nullptr;

pTarget->get_CurrentAutomationId(&automationId);
pTarget->get_CurrentControlType(&controlType);
Expand All @@ -545,6 +546,11 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
pTarget4->get_CurrentLevel(&level);
pTarget4->Release();
}
IUIAutomationElement6 *pTarget6;
hr = pTarget->QueryInterface(__uuidof(IUIAutomationElement6), reinterpret_cast<void **>(&pTarget6));
if (SUCCEEDED(hr) && pTarget6) {
pTarget6->get_CurrentFullDescription(&description);
}
result.Insert(L"AutomationId", winrt::Windows::Data::Json::JsonValue::CreateStringValue(automationId));
result.Insert(L"ControlType", winrt::Windows::Data::Json::JsonValue::CreateNumberValue(controlType));
InsertStringValueIfNotEmpty(result, L"HelpText", helpText);
Expand All @@ -560,6 +566,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
InsertStringValueIfNotEmpty(result, L"ItemStatus", itemStatus);
InsertStringValueIfNotEmpty(result, L"ItemType", itemType);
InsertStringValueIfNotEmpty(result, L"AccessKey", accessKey);
InsertStringValueIfNotEmpty(result, L"Description", description);
DumpUIAPatternInfo(pTarget, result);

IUIAutomationElement *pChild;
Expand All @@ -580,6 +587,9 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
::SysFreeString(localizedControlType);
::SysFreeString(name);
::SysFreeString(itemStatus);
::SysFreeString(itemType);
::SysFreeString(accessKey);
::SysFreeString(description);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPropertyValue(PROPERT
pRetVal->bstrVal = SysAllocString(itemtype.c_str());
break;
}
case UIA_FullDescriptionPropertyId: {
pRetVal->vt = VT_BSTR;
auto desc = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityDescription.value_or(""));
pRetVal->bstrVal = SysAllocString(desc.c_str());
break;
}
}
return hr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,12 @@ void ComponentView::updateAccessibilityProps(
oldViewProps.accessibilityItemType,
newViewProps.accessibilityItemType);

winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
EnsureUiaProvider(),
UIA_FullDescriptionPropertyId,
oldViewProps.accessibilityDescription,
newViewProps.accessibilityDescription);

if ((oldViewProps.accessibilityState.has_value() && oldViewProps.accessibilityState->selected.has_value()) !=
((newViewProps.accessibilityState.has_value() && newViewProps.accessibilityState->selected.has_value()))) {
auto compProvider =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ HostPlatformViewProps::HostPlatformViewProps(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.accessibilityAccessKey
: convertRawProp(context, rawProps, "accessibilityAccessKey", sourceProps.accessibilityAccessKey, {})),
accessibilityDescription(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter() ? sourceProps.accessibilityDescription
: convertRawProp(
context,
rawProps,
"accessibilityDescription",
sourceProps.accessibilityDescription,
{})),
accessibilityLiveRegion(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter() ? sourceProps.accessibilityLiveRegion
: convertRawProp(
Expand Down Expand Up @@ -104,6 +112,7 @@ void HostPlatformViewProps::setProp(
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLevel);
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityItemType);
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityAccessKey);
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityDescription);
RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLiveRegion);
RAW_SET_PROP_SWITCH_CASE_BASIC(keyDownEvents);
RAW_SET_PROP_SWITCH_CASE_BASIC(keyUpEvents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class HostPlatformViewProps : public BaseViewProps {
std::optional<AccessibilityAnnotation> accessibilityAnnotation{};
std::optional<std::string> accessibilityItemType{};
std::optional<std::string> accessibilityAccessKey{};
std::optional<std::string> accessibilityDescription{};

// std::optional<std::string> overflowAnchor{};
std::optional<std::string> tooltip{};
Expand Down
6 changes: 6 additions & 0 deletions vnext/src-win/Libraries/Components/View/View.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const View: component(
accessibilityLabel,
accessibilityLabelledBy,
accessibilityLevel, // Windows
accessibilityDescription, //Windows
accessibilityLiveRegion,
accessibilityPosInSet, // Windows
accessibilitySetSize, // Windows
Expand All @@ -78,6 +79,7 @@ const View: component(
'aria-expanded': ariaExpanded,
'aria-multiselectable': ariaMultiselectable, // Windows
'aria-required': ariaRequired, // Windows
'aria-description': ariaDescription, //Windows
'aria-hidden': ariaHidden,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
Expand Down Expand Up @@ -250,6 +252,7 @@ const View: component(
}
accessibilityLabel={ariaLabel ?? accessibilityLabel}
accessibilityLevel={ariaLevel ?? accessibilityLevel}
accessibilityDescription={ariaDescription ?? accessibilityDescription}
accessibilityPosInSet={ariaPosinset ?? accessibilityPosInSet}
accessibilitySetSize={ariaSetsize ?? accessibilitySetSize}
focusable={_focusable}
Expand Down Expand Up @@ -303,6 +306,9 @@ const View: component(
}
accessibilityLabel={ariaLabel ?? accessibilityLabel}
accessibilityLevel={ariaLevel ?? accessibilityLevel}
accessibilityDescription={
ariaDescription ?? accessibilityDescription
}
accessibilityPosInSet={ariaPosinset ?? accessibilityPosInSet}
accessibilitySetSize={ariaSetsize ?? accessibilitySetSize}
focusable={_focusable}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ export interface AccessibilityPropsWindows {
* Access keys are used in keyboard navigation to allow quick navigation to UI in an application.
*/
accessibilityAccessKey?: string; //Windows

/**
* accessibilityDescription provides more detailed information specific to the element (i.e. last edit date, full location for a file)
* while accessibilityHint provides information on what will happen when they perform an action.
*
*/
accessibilityDescription?: string; // Windows
'aria-description'?: string; // Windows
}

export interface AccessibilityPropsAndroid {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ type ViewPropsWindows = $ReadOnly<{|
'aria-posinset'?: ?number,
accessibilitySetSize?: ?number,
'aria-setsize'?: ?number,
accessibilityDescription?: ?string,
'aria-description'?: ?string,

/**
* Specifies if the control should show System focus visuals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ const validAttributesForNonEventProps = {
accessibilityAnnotation: true, // [Windows]
accessibilityItemType: true, // [Windows]
accessibilityAccessKey: true, // [Windows]
accessibilityDescription: true, // [Windows]
disabled: true, // [Windows]
focusable: true, // [Windows]
keyDownEvents: true, // [Windows]
Expand Down
Loading