11import * as React from 'react' ;
2- import { TouchableWithoutFeedback , View , ViewProps } from 'react-native' ;
2+ import {
3+ TouchableWithoutFeedback ,
4+ TouchableWithoutFeedbackProps ,
5+ View ,
6+ ViewProps ,
7+ } from 'react-native' ;
38
49import { useFocus } from '../hooks/useFocus' ;
10+ import { PickAccessibleProps } from '@react-native-ama/internal' ;
511
6- type AutofocusContainerProps = React . PropsWithChildren <
7- | ( {
8- wrapChildrenInAccessibleView ?: true ;
9- } & ViewProps )
10- | {
11- wrapChildrenInAccessibleView : false ;
12- }
12+ type TouchableAccessibleProps =
13+ PickAccessibleProps < TouchableWithoutFeedbackProps > ;
14+
15+ export type AutofocusContainerProps = React . PropsWithChildren <
16+ (
17+ | ( {
18+ wrapChildrenInAccessibleView ?: true ;
19+ } & ViewProps )
20+ | {
21+ wrapChildrenInAccessibleView : false ;
22+ }
23+ ) & {
24+ /**
25+ * touchableContainerAccessibilityProps is provided as a workaround for any accessibility props that need to be passed to the TouchableWithoutFeedback component which are not recognized on the accessible view.
26+ */
27+ touchableContainerAccessibilityProps ?: TouchableAccessibleProps ;
28+ }
1329> ;
1430
1531export const AutofocusContainer = ( {
1632 children,
1733 wrapChildrenInAccessibleView = true ,
34+ touchableContainerAccessibilityProps,
1835 ...viewProps
1936} : AutofocusContainerProps ) => {
2037 const containerRef = React . useRef ( null ) ;
@@ -27,7 +44,9 @@ export const AutofocusContainer = ({
2744 } , [ setFocus ] ) ;
2845
2946 return wrapChildrenInAccessibleView ? (
30- < TouchableWithoutFeedback ref = { containerRef } >
47+ < TouchableWithoutFeedback
48+ ref = { containerRef }
49+ { ...touchableContainerAccessibilityProps } >
3150 < View
3251 accessible = { true }
3352 testID = "autofocusContainer.accessibleView"
@@ -36,7 +55,9 @@ export const AutofocusContainer = ({
3655 </ View >
3756 </ TouchableWithoutFeedback >
3857 ) : (
39- < TouchableWithoutFeedback ref = { containerRef } >
58+ < TouchableWithoutFeedback
59+ ref = { containerRef }
60+ { ...touchableContainerAccessibilityProps } >
4061 { children }
4162 </ TouchableWithoutFeedback >
4263 ) ;
0 commit comments