Skip to content

Commit

Permalink
feat: add testID and accessibilityLabel to DrawerItem (#11168)
Browse files Browse the repository at this point in the history
Added support for testIDs for the tappable DrawerItem and the DrawerItem
label

Addresses
#7492 and
#8906

This was attempted before with
#11009 but that
PR was closed due to an update in the main branch.
  • Loading branch information
andrewtremblay committed Feb 12, 2023
1 parent d7ef2bf commit 99ff9f7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/drawer/src/views/DrawerItem.tsx
Expand Up @@ -81,6 +81,15 @@ type Props = {
* Whether label font should scale to respect Text Size accessibility settings.
*/
allowFontScaling?: boolean;

/**
* Accessibility label for drawer item.
*/
accessibilityLabel?: string;
/**
* ID to locate this drawer item in tests.
*/
testID?: string;
};

const LinkPressable = ({
Expand Down Expand Up @@ -160,6 +169,8 @@ export default function DrawerItem(props: Props) {
onPress,
pressColor,
pressOpacity,
testID,
accessibilityLabel,
...rest
} = props;

Expand All @@ -178,8 +189,10 @@ export default function DrawerItem(props: Props) {
style={[styles.container, { borderRadius, backgroundColor }, style]}
>
<LinkPressable
testID={testID}
onPress={onPress}
style={[styles.wrapper, { borderRadius }]}
accessibilityLabel={accessibilityLabel}
accessibilityRole="button"
accessibilityState={{ selected: focused }}
pressColor={pressColor}
Expand Down

0 comments on commit 99ff9f7

Please sign in to comment.