Skip to content

Commit d06ee25

Browse files
committed
Merge branch 'main' of github.com:MrMuzyk/react-native-paper into refactor/modrnize-badge-component
2 parents b87037e + 466d9c6 commit d06ee25

74 files changed

Lines changed: 713 additions & 822 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/components/ActivityIndicator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ const ActivityIndicator = ({
146146
style={[styles.container, style]}
147147
{...rest}
148148
accessible
149-
accessibilityRole="progressbar"
150-
accessibilityState={{ busy: animating }}
149+
role="progressbar"
150+
aria-busy={animating}
151151
>
152152
<Animated.View
153153
style={[{ width: size, height: size, opacity: fade }]}

src/components/Appbar/AppbarAction.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type Props = React.ComponentPropsWithoutRef<typeof IconButton> & {
3232
/**
3333
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
3434
*/
35-
accessibilityLabel?: string;
35+
'aria-label'?: string;
3636
/**
3737
* Function to execute on press.
3838
*/
@@ -79,7 +79,7 @@ const AppbarAction = ({
7979
icon,
8080
disabled,
8181
onPress,
82-
accessibilityLabel,
82+
'aria-label': ariaLabel,
8383
isLeading,
8484
theme: themeOverrides,
8585
ref,
@@ -101,7 +101,7 @@ const AppbarAction = ({
101101
iconColor={actionIconColor}
102102
icon={icon}
103103
disabled={disabled}
104-
accessibilityLabel={accessibilityLabel}
104+
aria-label={ariaLabel}
105105
animated
106106
ref={ref}
107107
{...rest}

src/components/Appbar/AppbarBackAction.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type Props = $Omit<
3131
/**
3232
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
3333
*/
34-
accessibilityLabel?: string;
34+
'aria-label'?: string;
3535
/**
3636
* Function to execute on press.
3737
*/
@@ -58,12 +58,12 @@ export type Props = $Omit<
5858
* ```
5959
*/
6060
const AppbarBackAction = ({
61-
accessibilityLabel = 'Back',
61+
'aria-label': ariaLabel = 'Back',
6262
ref,
6363
...rest
6464
}: Props) => (
6565
<AppbarAction
66-
accessibilityLabel={accessibilityLabel}
66+
aria-label={ariaLabel}
6767
{...rest}
6868
icon={AppbarBackIcon}
6969
isLeading

src/components/Appbar/AppbarContent.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
2-
import { Platform, StyleSheet, Pressable, View } from 'react-native';
2+
import { StyleSheet, Pressable, View } from 'react-native';
33
import type {
4-
AccessibilityRole,
54
GestureResponderEvent,
65
StyleProp,
76
TextStyle,
@@ -140,15 +139,7 @@ const AppbarContent = ({
140139
]}
141140
numberOfLines={1}
142141
accessible
143-
accessibilityRole={
144-
onPress
145-
? 'none'
146-
: Platform.OS === 'web'
147-
? ('heading' as 'header')
148-
: 'header'
149-
}
150-
// @ts-expect-error We keep old a11y props for backwards compat with old RN versions
151-
accessibilityTraits="header"
142+
role={onPress ? 'none' : 'heading'}
152143
testID={`${testID}-title-text`}
153144
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
154145
>
@@ -162,13 +153,9 @@ const AppbarContent = ({
162153

163154
if (onPress) {
164155
return (
165-
// eslint-disable-next-line react-native-a11y/has-accessibility-props
166156
<Pressable
167-
accessibilityRole={touchableRole}
168-
// @ts-expect-error We keep old a11y props for backwards compat with old RN versions
169-
accessibilityTraits={touchableRole}
170-
accessibilityComponentType="button"
171-
accessbilityState={disabled ? 'disabled' : null}
157+
role="button"
158+
aria-disabled={disabled}
172159
onPress={onPress}
173160
disabled={disabled}
174161
{...contentWrapperProps}
@@ -204,8 +191,6 @@ const styles = StyleSheet.create({
204191
},
205192
});
206193

207-
const touchableRole: AccessibilityRole = 'button';
208-
209194
export default AppbarContent;
210195

211196
// @component-docs ignore-next-line

src/components/Banner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ const Banner = ({
232232
color: colors.onSurface,
233233
},
234234
]}
235-
accessibilityLiveRegion={visible ? 'polite' : 'none'}
236-
accessibilityRole="alert"
235+
aria-live={visible ? 'polite' : 'off'}
236+
role="alert"
237237
maxFontSizeMultiplier={maxFontSizeMultiplier}
238238
>
239239
{children}

src/components/BottomNavigation/BottomNavigation.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type BaseRoute = {
2323
focusedIcon?: IconSource;
2424
unfocusedIcon?: IconSource;
2525
badge?: string | number | boolean;
26-
accessibilityLabel?: string;
26+
'aria-label'?: string;
2727
testID?: string;
2828
lazy?: boolean;
2929
};
@@ -77,7 +77,7 @@ export type Props<Route extends BaseRoute> = {
7777
* - `focusedIcon`: icon to use as the focused tab icon, can be a string, an image source or a react component @renamed Renamed from 'icon' to 'focusedIcon' in v5.x
7878
* - `unfocusedIcon`: icon to use as the unfocused tab icon, can be a string, an image source or a react component @supported Available in v5.x with theme version 3
7979
* - `badge`: badge to show on the tab icon, can be `true` to show a dot, `string` or `number` to show text.
80-
* - `accessibilityLabel`: accessibility label for the tab button
80+
* - `aria-label`: accessibility label for the tab button
8181
* - `testID`: test id for the tab button
8282
*
8383
* Example:
@@ -164,7 +164,7 @@ export type Props<Route extends BaseRoute> = {
164164
renderTouchable?: (props: TouchableProps<Route>) => React.ReactNode;
165165
/**
166166
* Get accessibility label for the tab button. This is read by the screen reader when the user taps the tab.
167-
* Uses `route.accessibilityLabel` by default.
167+
* Uses `route['aria-label']` by default.
168168
*/
169169
getAccessibilityLabel?: (props: { route: Route }) => string | undefined;
170170
/**
@@ -523,7 +523,7 @@ const BottomNavigation = <Route extends BaseRoute>({
523523
<BottomNavigationRouteScreen
524524
key={route.key}
525525
pointerEvents={focused ? 'auto' : 'none'}
526-
accessibilityElementsHidden={!focused}
526+
aria-hidden={!focused}
527527
importantForAccessibility={
528528
focused ? 'auto' : 'no-hide-descendants'
529529
}

src/components/BottomNavigation/BottomNavigationBar.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ type BaseRoute = {
3434
focusedIcon?: IconSource;
3535
unfocusedIcon?: IconSource;
3636
badge?: string | number | boolean;
37-
accessibilityLabel?: string;
37+
/**
38+
* Accessibility label for the tab. This is read by the screen reader when the user focuses the tab.
39+
*/
40+
'aria-label'?: string;
3841
testID?: string;
3942
lazy?: boolean;
4043
};
@@ -88,7 +91,7 @@ export type Props<Route extends BaseRoute> = {
8891
* - `focusedIcon`: icon to use as the focused tab icon, can be a string, an image source or a react component @renamed Renamed from 'icon' to 'focusedIcon' in v5.x
8992
* - `unfocusedIcon`: icon to use as the unfocused tab icon, can be a string, an image source or a react component @supported Available in v5.x with theme version 3
9093
* - `badge`: badge to show on the tab icon, can be `true` to show a dot, `string` or `number` to show text.
91-
* - `accessibilityLabel`: accessibility label for the tab button
94+
* - `aria-label`: accessibility label for the tab button
9295
* - `testID`: test id for the tab button
9396
*
9497
* Example:
@@ -131,7 +134,7 @@ export type Props<Route extends BaseRoute> = {
131134
renderTouchable?: (props: TouchableProps<Route>) => React.ReactNode;
132135
/**
133136
* Get accessibility label for the tab button. This is read by the screen reader when the user taps the tab.
134-
* Uses `route.accessibilityLabel` by default.
137+
* Uses `route['aria-label']` by default.
135138
*/
136139
getAccessibilityLabel?: (props: { route: Route }) => string | undefined;
137140
/**
@@ -305,8 +308,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
305308
),
306309
getLabelText = ({ route }: { route: Route }) => route.title,
307310
getBadge = ({ route }: { route: Route }) => route.badge,
308-
getAccessibilityLabel = ({ route }: { route: Route }) =>
309-
route.accessibilityLabel,
311+
getAccessibilityLabel = ({ route }: { route: Route }) => route['aria-label'],
310312
getTestID = ({ route }: { route: Route }) => route.testID,
311313
activeColor,
312314
inactiveColor,
@@ -507,7 +509,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
507509
maxWidth: maxTabBarWidth,
508510
},
509511
]}
510-
accessibilityRole={'tablist'}
512+
role={'tablist'}
511513
testID={`${testID}-content-wrapper`}
512514
>
513515
{routes.map((route, index) => {
@@ -585,9 +587,9 @@ const BottomNavigationBar = <Route extends BaseRoute>({
585587
onPress: () => onTabPress(eventForIndex(index)),
586588
onLongPress: () => onTabLongPress?.(eventForIndex(index)),
587589
testID: getTestID({ route }),
588-
accessibilityLabel: getAccessibilityLabel({ route }),
589-
accessibilityRole: Platform.OS === 'ios' ? 'button' : 'tab',
590-
accessibilityState: { selected: focused },
590+
'aria-label': getAccessibilityLabel({ route }),
591+
role: Platform.OS === 'ios' ? 'button' : 'tab',
592+
'aria-selected': focused,
591593
style: [styles.item, styles.v3Item],
592594
children: (
593595
<View

src/components/Button/Button.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as React from 'react';
22
import { Animated, Platform, StyleSheet, View } from 'react-native';
33
import type {
4-
AccessibilityRole,
54
ColorValue,
65
GestureResponderEvent,
76
PressableAndroidRippleConfig,
7+
Role,
88
StyleProp,
99
TextStyle,
1010
ViewStyle,
@@ -80,15 +80,15 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
8080
/**
8181
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
8282
*/
83-
accessibilityLabel?: string;
83+
'aria-label'?: string;
8484
/**
8585
* Accessibility hint for the button. This is read by the screen reader when the user taps the button.
8686
*/
8787
accessibilityHint?: string;
8888
/**
8989
* Accessibility role for the button. The "button" role is set by default.
9090
*/
91-
accessibilityRole?: AccessibilityRole;
91+
role?: Role;
9292
/**
9393
* Function to execute on press.
9494
*/
@@ -169,9 +169,9 @@ const Button = ({
169169
buttonColor: customButtonColor,
170170
textColor: customTextColor,
171171
children,
172-
accessibilityLabel,
172+
'aria-label': ariaLabel,
173173
accessibilityHint,
174-
accessibilityRole = 'button',
174+
role = 'button',
175175
hitSlop,
176176
onPress,
177177
onPressIn,
@@ -352,10 +352,10 @@ const Button = ({
352352
onPressIn={hasPassedTouchHandler ? handlePressIn : undefined}
353353
onPressOut={hasPassedTouchHandler ? handlePressOut : undefined}
354354
delayLongPress={delayLongPress}
355-
accessibilityLabel={accessibilityLabel}
355+
aria-label={ariaLabel}
356356
accessibilityHint={accessibilityHint}
357-
accessibilityRole={accessibilityRole}
358-
accessibilityState={{ disabled }}
357+
role={role}
358+
aria-disabled={disabled}
359359
accessible={accessible}
360360
hitSlop={hitSlop}
361361
disabled={disabled}

src/components/Checkbox/Checkbox.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,12 @@ const Checkbox = ({
247247
rest.accessible === false
248248
? {}
249249
: {
250-
accessibilityRole: 'checkbox' as const,
251-
accessibilityState: {
252-
disabled: !!disabled,
253-
checked: (status === 'indeterminate'
254-
? 'mixed'
255-
: status === 'checked') as boolean | 'mixed',
256-
},
257-
accessibilityLiveRegion: 'polite' as const,
250+
role: 'checkbox' as const,
251+
'aria-disabled': !!disabled,
252+
'aria-checked': (status === 'indeterminate'
253+
? 'mixed'
254+
: status === 'checked') as boolean | 'mixed',
255+
'aria-live': 'polite' as const,
258256
};
259257

260258
return (

src/components/Checkbox/CheckboxItem.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export type Props = {
4444
/**
4545
* Accessibility label for the touchable. This is read by the screen reader when the user taps the touchable.
4646
*/
47-
accessibilityLabel?: string;
47+
'aria-label'?: string;
4848
/**
4949
* Custom color for unchecked checkbox.
5050
*/
@@ -129,7 +129,7 @@ const CheckboxItem = ({
129129
theme: themeOverrides,
130130
testID,
131131
position = 'trailing',
132-
accessibilityLabel = label,
132+
'aria-label': ariaLabel = label,
133133
disabled,
134134
labelVariant = 'bodyLarge',
135135
labelMaxFontSizeMultiplier = 1.5,
@@ -154,12 +154,10 @@ const CheckboxItem = ({
154154

155155
return (
156156
<TouchableRipple
157-
accessibilityLabel={accessibilityLabel}
158-
accessibilityRole="checkbox"
159-
accessibilityState={{
160-
checked: status === 'indeterminate' ? 'mixed' : status === 'checked',
161-
disabled,
162-
}}
157+
aria-label={ariaLabel}
158+
role="checkbox"
159+
aria-checked={status === 'indeterminate' ? 'mixed' : status === 'checked'}
160+
aria-disabled={disabled}
163161
onPress={onPress}
164162
onLongPress={onLongPress}
165163
testID={testID}

0 commit comments

Comments
 (0)