Skip to content

Commit 401b1d7

Browse files
Merge pull request #60 from a7medev/feat/improve-a11y
feat: improve accessibility
2 parents cb26cee + b4cb818 commit 401b1d7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

lib/RadioButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ export default function RadioButton({
5353
{ opacity: disabled ? 0.2 : 1 },
5454
containerStyle,
5555
]}
56+
disabled={disabled}
5657
testID={testID}
57-
accessibilityLabel={accessibilityLabel}
58+
accessibilityRole="radio"
59+
accessibilityLabel={label || accessibilityLabel}
60+
accessibilityHint={description}
61+
accessibilityState={{ checked: selected, disabled }}
5862
>
5963
<View
6064
style={[

lib/RadioGroup.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { StyleSheet, View } from 'react-native';
44
import RadioButton from './RadioButton';
55
import { RadioGroupProps } from './types';
66

7-
export default function RadioGroup({ containerStyle, layout = 'column', onPress, radioButtons, selectedId, testID}: RadioGroupProps) {
7+
export default function RadioGroup({ accessibilityLabel, containerStyle, layout = 'column', onPress, radioButtons, selectedId, testID}: RadioGroupProps) {
88

99
function handlePress(id: string) {
1010
if(id !== selectedId && onPress) {
@@ -13,7 +13,12 @@ export default function RadioGroup({ containerStyle, layout = 'column', onPress,
1313
}
1414

1515
return (
16-
<View style={[styles.container, { flexDirection: layout }, containerStyle]} testID={testID}>
16+
<View
17+
style={[styles.container, { flexDirection: layout }, containerStyle]}
18+
testID={testID}
19+
accessibilityLabel={accessibilityLabel}
20+
accessibilityRole="radiogroup"
21+
>
1722
{radioButtons.map((button) => (
1823
<RadioButton
1924
{...button}

lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type RadioButtonProps = {
2222
};
2323

2424
export type RadioGroupProps = {
25+
accessibilityLabel?: string;
2526
containerStyle?: StyleProp<ViewStyle>;
2627
layout?: 'row' | 'column';
2728
onPress?: (selectedId: string) => void;

0 commit comments

Comments
 (0)