Skip to content

Commit fb65967

Browse files
authored
feat: add accessibilityLabel prop to DrawerItem (#1622)
1 parent 87f15b5 commit fb65967

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/components/Drawer/DrawerItem.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ type Props = {
2424
* Function to execute on press.
2525
*/
2626
onPress?: () => void;
27+
/**
28+
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
29+
*/
30+
accessibilityLabel?: string;
2731
style?: StyleProp<ViewStyle>;
2832
/**
2933
* @optional
@@ -50,7 +54,16 @@ class DrawerItem extends React.Component<Props> {
5054
static displayName = 'Drawer.Item';
5155

5256
render() {
53-
const { icon, label, active, theme, style, onPress, ...rest } = this.props;
57+
const {
58+
icon,
59+
label,
60+
active,
61+
theme,
62+
style,
63+
onPress,
64+
accessibilityLabel,
65+
...rest
66+
} = this.props;
5467
const { colors, roundness } = theme;
5568
const backgroundColor = active
5669
? color(colors.primary)
@@ -85,6 +98,7 @@ class DrawerItem extends React.Component<Props> {
8598
accessibilityComponentType="button"
8699
accessibilityRole="button"
87100
accessibilityStates={active ? ['selected'] : []}
101+
accessibilityLabel={accessibilityLabel}
88102
>
89103
<View style={styles.wrapper}>
90104
{icon ? (

0 commit comments

Comments
 (0)