Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/ActivityIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ const ActivityIndicator = ({
style={[styles.container, style]}
{...rest}
accessible
accessibilityRole="progressbar"
accessibilityState={{ busy: animating }}
role="progressbar"
aria-busy={animating}
>
<Animated.View
style={[{ width: size, height: size, opacity: fade }]}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Appbar/AppbarAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type Props = React.ComponentPropsWithoutRef<typeof IconButton> & {
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
accessibilityLabel?: string;
'aria-label'?: string;
/**
* Function to execute on press.
*/
Expand Down Expand Up @@ -79,7 +79,7 @@ const AppbarAction = ({
icon,
disabled,
onPress,
accessibilityLabel,
'aria-label': ariaLabel,
isLeading,
theme: themeOverrides,
ref,
Expand All @@ -101,7 +101,7 @@ const AppbarAction = ({
iconColor={actionIconColor}
icon={icon}
disabled={disabled}
accessibilityLabel={accessibilityLabel}
aria-label={ariaLabel}
animated
ref={ref}
{...rest}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Appbar/AppbarBackAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type Props = $Omit<
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
accessibilityLabel?: string;
'aria-label'?: string;
/**
* Function to execute on press.
*/
Expand All @@ -58,12 +58,12 @@ export type Props = $Omit<
* ```
*/
const AppbarBackAction = ({
accessibilityLabel = 'Back',
'aria-label': ariaLabel = 'Back',
ref,
...rest
}: Props) => (
<AppbarAction
accessibilityLabel={accessibilityLabel}
aria-label={ariaLabel}
{...rest}
icon={AppbarBackIcon}
isLeading
Expand Down
22 changes: 4 additions & 18 deletions src/components/Appbar/AppbarContent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { Platform, StyleSheet, Pressable, View } from 'react-native';
import { StyleSheet, Pressable, View } from 'react-native';
import type {
AccessibilityRole,
GestureResponderEvent,
StyleProp,
TextStyle,
Expand Down Expand Up @@ -140,15 +139,7 @@ const AppbarContent = ({
]}
numberOfLines={1}
accessible
accessibilityRole={
onPress
? 'none'
: Platform.OS === 'web'
? ('heading' as 'header')
: 'header'
}
// @ts-expect-error We keep old a11y props for backwards compat with old RN versions
accessibilityTraits="header"
role={onPress ? 'none' : 'heading'}
testID={`${testID}-title-text`}
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
>
Expand All @@ -164,11 +155,8 @@ const AppbarContent = ({
return (
// eslint-disable-next-line react-native-a11y/has-accessibility-props
<Pressable
accessibilityRole={touchableRole}
// @ts-expect-error We keep old a11y props for backwards compat with old RN versions
accessibilityTraits={touchableRole}
accessibilityComponentType="button"
accessbilityState={disabled ? 'disabled' : null}
role="button"
aria-disabled={disabled}
onPress={onPress}
disabled={disabled}
{...contentWrapperProps}
Expand Down Expand Up @@ -204,8 +192,6 @@ const styles = StyleSheet.create({
},
});

const touchableRole: AccessibilityRole = 'button';

export default AppbarContent;

// @component-docs ignore-next-line
Expand Down
4 changes: 2 additions & 2 deletions src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ const Banner = ({
color: colors.onSurface,
},
]}
accessibilityLiveRegion={visible ? 'polite' : 'none'}
accessibilityRole="alert"
aria-live={visible ? 'polite' : 'off'}
role="alert"
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/BottomNavigation/BottomNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ const BottomNavigation = <Route extends BaseRoute>({
<BottomNavigationRouteScreen
key={route.key}
pointerEvents={focused ? 'auto' : 'none'}
accessibilityElementsHidden={!focused}
aria-hidden={!focused}
importantForAccessibility={
focused ? 'auto' : 'no-hide-descendants'
}
Expand Down
16 changes: 9 additions & 7 deletions src/components/BottomNavigation/BottomNavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ type BaseRoute = {
focusedIcon?: IconSource;
unfocusedIcon?: IconSource;
badge?: string | number | boolean;
accessibilityLabel?: string;
/**
* Accessibility label for the tab. This is read by the screen reader when the user focuses the tab.
*/
'aria-label'?: string;
testID?: string;
lazy?: boolean;
};
Expand Down Expand Up @@ -305,8 +308,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
),
getLabelText = ({ route }: { route: Route }) => route.title,
getBadge = ({ route }: { route: Route }) => route.badge,
getAccessibilityLabel = ({ route }: { route: Route }) =>
route.accessibilityLabel,
getAccessibilityLabel = ({ route }: { route: Route }) => route['aria-label'],
getTestID = ({ route }: { route: Route }) => route.testID,
activeColor,
inactiveColor,
Expand Down Expand Up @@ -507,7 +509,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
maxWidth: maxTabBarWidth,
},
]}
accessibilityRole={'tablist'}
role={'tablist'}
testID={`${testID}-content-wrapper`}
>
{routes.map((route, index) => {
Expand Down Expand Up @@ -585,9 +587,9 @@ const BottomNavigationBar = <Route extends BaseRoute>({
onPress: () => onTabPress(eventForIndex(index)),
onLongPress: () => onTabLongPress?.(eventForIndex(index)),
testID: getTestID({ route }),
accessibilityLabel: getAccessibilityLabel({ route }),
accessibilityRole: Platform.OS === 'ios' ? 'button' : 'tab',
accessibilityState: { selected: focused },
'aria-label': getAccessibilityLabel({ route }),
role: Platform.OS === 'ios' ? 'button' : 'tab',
'aria-selected': focused,
style: [styles.item, styles.v3Item],
children: (
<View
Expand Down
15 changes: 7 additions & 8 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { Animated, Platform, StyleSheet, View } from 'react-native';
import type {
AccessibilityRole,
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
Expand Down Expand Up @@ -80,15 +79,15 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
accessibilityLabel?: string;
'aria-label'?: string;
/**
* Accessibility hint for the button. This is read by the screen reader when the user taps the button.
*/
accessibilityHint?: string;
/**
* Accessibility role for the button. The "button" role is set by default.
*/
accessibilityRole?: AccessibilityRole;
role?: string;
/**
* Function to execute on press.
*/
Expand Down Expand Up @@ -169,9 +168,9 @@ const Button = ({
buttonColor: customButtonColor,
textColor: customTextColor,
children,
accessibilityLabel,
'aria-label': ariaLabel,
accessibilityHint,
accessibilityRole = 'button',
role = 'button',
hitSlop,
onPress,
onPressIn,
Expand Down Expand Up @@ -352,10 +351,10 @@ const Button = ({
onPressIn={hasPassedTouchHandler ? handlePressIn : undefined}
onPressOut={hasPassedTouchHandler ? handlePressOut : undefined}
delayLongPress={delayLongPress}
accessibilityLabel={accessibilityLabel}
aria-label={ariaLabel}
accessibilityHint={accessibilityHint}
accessibilityRole={accessibilityRole}
accessibilityState={{ disabled }}
role={role}
aria-disabled={disabled}
accessible={accessible}
hitSlop={hitSlop}
disabled={disabled}
Expand Down
14 changes: 6 additions & 8 deletions src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,12 @@ const Checkbox = ({
rest.accessible === false
? {}
: {
accessibilityRole: 'checkbox' as const,
accessibilityState: {
disabled: !!disabled,
checked: (status === 'indeterminate'
? 'mixed'
: status === 'checked') as boolean | 'mixed',
},
accessibilityLiveRegion: 'polite' as const,
role: 'checkbox' as const,
'aria-disabled': !!disabled,
'aria-checked': (status === 'indeterminate'
? 'mixed'
: status === 'checked') as boolean | 'mixed',
'aria-live': 'polite' as const,
};

return (
Expand Down
14 changes: 6 additions & 8 deletions src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type Props = {
/**
* Accessibility label for the touchable. This is read by the screen reader when the user taps the touchable.
*/
accessibilityLabel?: string;
'aria-label'?: string;
/**
* Custom color for unchecked checkbox.
*/
Expand Down Expand Up @@ -129,7 +129,7 @@ const CheckboxItem = ({
theme: themeOverrides,
testID,
position = 'trailing',
accessibilityLabel = label,
'aria-label': ariaLabel = label,
disabled,
labelVariant = 'bodyLarge',
labelMaxFontSizeMultiplier = 1.5,
Expand All @@ -154,12 +154,10 @@ const CheckboxItem = ({

return (
<TouchableRipple
accessibilityLabel={accessibilityLabel}
accessibilityRole="checkbox"
accessibilityState={{
checked: status === 'indeterminate' ? 'mixed' : status === 'checked',
disabled,
}}
aria-label={ariaLabel}
role="checkbox"
aria-checked={status === 'indeterminate' ? 'mixed' : status === 'checked'}
aria-disabled={disabled}
onPress={onPress}
onLongPress={onLongPress}
testID={testID}
Expand Down
23 changes: 9 additions & 14 deletions src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { Animated, Platform, StyleSheet, Pressable, View } from 'react-native';
import type {
AccessibilityState,
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
Expand Down Expand Up @@ -81,7 +80,7 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
/**
* Accessibility label for the chip. This is read by the screen reader when the user taps the chip.
*/
accessibilityLabel?: string;
'aria-label'?: string;
/**
* Accessibility label for the close icon. This is read by the screen reader when the user taps the close icon.
*/
Expand Down Expand Up @@ -178,8 +177,8 @@ const Chip = ({
selected = false,
disabled = false,
background,
accessibilityLabel,
accessibilityRole = 'button',
'aria-label': ariaLabel,
role = 'button',
closeIconAccessibilityLabel = 'Close',
onPress,
onLongPress,
Expand Down Expand Up @@ -263,11 +262,6 @@ const Chip = ({
disabled,
});

const accessibilityState: AccessibilityState = {
selected,
disabled,
};

const elevationStyle = elevation;
const multiplier = compact ? 1.5 : 2;
const labelSpacings = {
Expand Down Expand Up @@ -312,9 +306,10 @@ const Chip = ({
onPressOut={hasPassedTouchHandler ? handlePressOut : undefined}
delayLongPress={delayLongPress}
disabled={disabled}
accessibilityLabel={accessibilityLabel}
accessibilityRole={accessibilityRole}
accessibilityState={accessibilityState}
aria-label={ariaLabel}
role={role}
aria-selected={selected}
aria-disabled={disabled}
testID={testID}
theme={theme}
hitSlop={hitSlop}
Expand Down Expand Up @@ -401,8 +396,8 @@ const Chip = ({
<Pressable
onPress={onClose}
disabled={disabled}
accessibilityRole="button"
accessibilityLabel={closeIconAccessibilityLabel}
role="button"
aria-label={closeIconAccessibilityLabel}
>
<View style={[styles.icon, styles.closeIcon, styles.md3CloseIcon]}>
{closeIcon ? (
Expand Down
Loading