Skip to content

Add support for accessibilityDescription prop. #14585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "accessibilityDescriptionProp impl",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
16 changes: 16 additions & 0 deletions packages/playground/Samples/accessible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ export default class Bootstrap extends React.Component<
<Text style={styles.text}>TEST setAccessibilityFocus</Text>
</TouchableHighlight>
<TextInput ref={this.myElement} />

<TouchableHighlight
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically leave these sample pages as they are. If you want to add an example of the prop, add an example to a JS/TS file in the rntester app (i.e. the files that have the *Example syntax). I would add an example to AccessibilityExampleWindows.tsx

style={styles.item}
accessibilityLabel="Test accessibilityDescription prop"
accessible={true}
accessibilityHint="Full Description for the accessibilty control on Group"
{...{
// Use weird format as work around for the fact that these props are not part of the @types/react-native yet
focusable: true,
}}>
<Text
style={styles.text}
accessibilityHint="Full Description for the accessibilty control on Text">
TEST Accessibility Description
</Text>
</TouchableHighlight>
</View>
);
}
Expand Down
4 changes: 4 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ winrt::hstring ViewProps::AccessibilityLabel() noexcept {
return m_viewProps ? winrt::to_hstring(m_viewProps->accessibilityLabel) : winrt::hstring{};
}

winrt::hstring ViewProps::AccessibilityHint() noexcept {
return m_viewProps ? winrt::to_hstring(m_viewProps->accessibilityHint) : winrt::hstring{};
}

ImageProps::ImageProps(facebook::react::SharedViewProps props) noexcept : Super(props) {}

winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::ReactNative::ImageSource>
Expand Down
1 change: 1 addition & 0 deletions vnext/Microsoft.ReactNative/Fabric/AbiViewProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct ViewProps : ViewPropsT<ViewProps> {
winrt::Microsoft::ReactNative::Color BackgroundColor() noexcept;
winrt::hstring TestId() noexcept;
winrt::hstring AccessibilityLabel() noexcept;
winrt::hstring AccessibilityHint() noexcept;

protected:
facebook::react::SharedViewProps m_props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,15 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPropertyValue(PROPERT
: SysAllocString(L"");
break;
}
case UIA_FullDescriptionPropertyId: {
pRetVal->vt = VT_BSTR;
auto helpText = props->accessibilityHint.empty()
? ::Microsoft::Common::Unicode::Utf8ToUtf16(compositionView->DefaultHelpText())
: ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityHint);
pRetVal->bstrVal = SysAllocString(helpText.c_str());
hr = pRetVal->bstrVal != nullptr ? S_OK : E_OUTOFMEMORY;
break;
}
}

return hr;
Expand Down
1 change: 1 addition & 0 deletions vnext/Microsoft.ReactNative/ViewProps.idl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace Microsoft.ReactNative {
Color BackgroundColor { get; };
String TestId { get; };
String AccessibilityLabel { get; };
String AccessibilityHint { get; };

// TODO add accessors to all the properties on ViewProps
};
Expand Down
Loading