@@ -16,6 +16,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1616import { isMobile } from '@libs/Browser' ;
1717import getOperatingSystem from '@libs/getOperatingSystem' ;
1818import CONST from '@src/CONST' ;
19+ import getAccessibilityLabelConfig from './getAccessibilityLabelConfig' ;
1920import type { BasePickerProps } from './types' ;
2021
2122type IconToRender = ( ) => ReactElement ;
@@ -46,7 +47,7 @@ function BasePicker<TPickerValue>({
4647 const { translate} = useLocalize ( ) ;
4748 const theme = useTheme ( ) ;
4849 const styles = useThemeStyles ( ) ;
49-
50+ const { shouldAnnounceSelectedLabel , shouldUseCustomAccessibilityLabel } = getAccessibilityLabelConfig ( ) ;
5051 const [ isHighlighted , setIsHighlighted ] = useState ( false ) ;
5152
5253 // reference to the root View
@@ -166,6 +167,19 @@ function BasePicker<TPickerValue>({
166167 // Disable Tab focus on mobile to prevent soft keyboard navigation jumping to picker (#25759)
167168 const pickerTabIndex = isMobile ( ) ? - 1 : 0 ;
168169
170+ const selectedItem = items . find ( ( item ) => item . value === value ) ;
171+ const selectedLabel = selectedItem ?. label ?? '' ;
172+ const defaultAccessibilityLabel = accessibilityLabel ?? label ?? selectedLabel ;
173+ const enhancedAccessibilityLabel = useMemo ( ( ) => {
174+ if ( ! defaultAccessibilityLabel ) {
175+ return selectedLabel || '' ;
176+ }
177+ if ( selectedLabel ) {
178+ return `${ defaultAccessibilityLabel } ${ shouldAnnounceSelectedLabel ? `, ${ selectedLabel } ` : '' } , ${ translate ( isHighlighted ? 'common.expanded' : 'common.collapsed' ) } ` ;
179+ }
180+ return defaultAccessibilityLabel ;
181+ } , [ defaultAccessibilityLabel , selectedLabel , shouldAnnounceSelectedLabel , translate , isHighlighted ] ) ;
182+
169183 if ( isDisabled && shouldShowOnlyTextWhenDisabled ) {
170184 return (
171185 < View >
@@ -183,6 +197,8 @@ function BasePicker<TPickerValue>({
183197 ) ;
184198 }
185199
200+ const actualAccessibilityLabel = shouldUseCustomAccessibilityLabel ? enhancedAccessibilityLabel : defaultAccessibilityLabel ;
201+
186202 return (
187203 < >
188204 < View
@@ -211,6 +227,8 @@ function BasePicker<TPickerValue>({
211227 onClose = { disableHighlight }
212228 textInputProps = { {
213229 allowFontScaling : false ,
230+ accessibilityRole : CONST . ROLE . COMBOBOX ,
231+ accessibilityLabel : actualAccessibilityLabel ,
214232 importantForAccessibility : 'no-hide-descendants' ,
215233 } }
216234 touchableDoneProps = { {
@@ -220,8 +238,7 @@ function BasePicker<TPickerValue>({
220238 touchableWrapperProps = { {
221239 accessible : true ,
222240 accessibilityRole : CONST . ROLE . COMBOBOX ,
223- accessibilityLabel,
224- accessibilityState : { disabled : isDisabled , expanded : isHighlighted } ,
241+ accessibilityLabel : actualAccessibilityLabel ,
225242 } }
226243 pickerProps = { {
227244 ref : picker ,
@@ -231,7 +248,8 @@ function BasePicker<TPickerValue>({
231248 disableHighlight ( ) ;
232249 onBlur ( ) ;
233250 } ,
234- accessibilityLabel,
251+ accessibilityLabel : actualAccessibilityLabel ,
252+ accessibilityRole : CONST . ROLE . COMBOBOX ,
235253 ...additionalPickerEvents ( enableHighlight , ( inputValue , index ) => {
236254 onValueChange ( inputValue , index ) ;
237255 disableHighlight ( ) ;
0 commit comments