-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Accessibility - Pressable does not render with aria-checked #2403
Comments
I see support for this was removed in 174ebb3 with the comment" Remove deprecated accessibility APIs", but I don't see any reference to accessibilityState being deprecated at https://reactnative.dev/docs/accessibility |
I've also seen #2372 and have left a comment there. As react-native doesn't currently support the accessibilityChecked prop, I don't understand how to use get |
Use
Use Platform.select until RN releases support for |
Thanks! I still need to figure out typing, but I think I can create a utility like this: const getAccessibilityStateProps = (accessibilityState: {
disabled?: boolean;
selected?: boolean;
checked?: boolean | "mixed";
busy?: boolean;
expanded?: boolean;
}) =>
Platform.select({
web: {
accessibilityDisabled: accessibilityState.disabled,
accessibilitySelected: accessibilityState.selected,
accessibilityChecked: accessibilityState.checked,
accessibilityBusy: accessibilityState.busy,
accessibilityExpanded: accessibilityState.expanded
},
default: { accessibilityState }
}); and have wrapped this in a little library called react-native-accessibility-props that can be used like this import { Pressable } from "react-native";
import { getAccessibilityStateProps } from "react-native-accessibility-props";
export default function App() {
return (
<Pressable
accessibilityRole="radio"
accessibilityLabel="label"
{...getAccessibilityStateProps({ checked: true })}
>
Example
</Pressable>
);
} Seems to work, other than the types, which I'll think about and hopefully publish an update. https://codesandbox.io/s/react-native-accessibility-props-0vpn1r I'll probably add another utility for all other accessibility& props too. |
Is there an existing issue for this?
Describe the issue
The following code
renders as
Which includes the label and role attributes but does not include
aria-checked
Expected behavior
Should render as
Steps to reproduce
react-native-web@0.18.9
As per code code sandbox test case.
Test case
https://codesandbox.io/s/react-native-web-checked-1ej4me
Additional comments
No response
The text was updated successfully, but these errors were encountered: