File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
import {
3
+ AccessibilityState ,
3
4
GestureResponderEvent ,
4
5
StyleProp ,
5
6
StyleSheet ,
@@ -69,6 +70,10 @@ export type Props = {
69
70
* Accessibility label for the Touchable. This is read by the screen reader when the user taps the component.
70
71
*/
71
72
accessibilityLabel ?: string ;
73
+ /**
74
+ * Accessibility state for the Touchable. This is read by the screen reader when the user taps the component.
75
+ */
76
+ accessibilityState ?: AccessibilityState ;
72
77
} ;
73
78
74
79
/**
@@ -111,6 +116,7 @@ const MenuItem = ({
111
116
testID,
112
117
titleStyle,
113
118
accessibilityLabel,
119
+ accessibilityState,
114
120
theme : themeOverrides ,
115
121
} : Props ) => {
116
122
const theme = useInternalTheme ( themeOverrides ) ;
@@ -138,6 +144,8 @@ const MenuItem = ({
138
144
...( isV3 ? theme . fonts . bodyLarge : { } ) ,
139
145
} ;
140
146
147
+ const newAccessibilityState = { ...accessibilityState , disabled } ;
148
+
141
149
return (
142
150
< TouchableRipple
143
151
style = { [
@@ -151,7 +159,7 @@ const MenuItem = ({
151
159
testID = { testID }
152
160
accessibilityLabel = { accessibilityLabel }
153
161
accessibilityRole = "menuitem"
154
- accessibilityState = { { disabled } }
162
+ accessibilityState = { newAccessibilityState }
155
163
underlayColor = { underlayColor }
156
164
>
157
165
< View style = { styles . row } >
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
3
+ import { render } from '@testing-library/react-native' ;
3
4
import color from 'color' ;
4
5
import renderer from 'react-test-renderer' ;
5
6
@@ -170,3 +171,17 @@ it('renders menu item', () => {
170
171
171
172
expect ( tree ) . toMatchSnapshot ( ) ;
172
173
} ) ;
174
+
175
+ it ( 'accepts different values for accessibilityState' , ( ) => {
176
+ const { getByTestId } = render (
177
+ < Menu . Item
178
+ accessibilityState = { { checked : true } }
179
+ title = "Option 1"
180
+ testID = "touchable"
181
+ />
182
+ ) ;
183
+
184
+ expect ( getByTestId ( 'touchable' ) . props . accessibilityState ) . toMatchObject ( {
185
+ checked : true ,
186
+ } ) ;
187
+ } ) ;
You can’t perform that action at this time.
0 commit comments