@@ -23,6 +23,7 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
2323 theme = { } ,
2424 textInputProps,
2525 textProps,
26+ buttonProps,
2627 type = "numeric" ,
2728 } = props ;
2829 const {
@@ -82,7 +83,13 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
8283 disabled = { disabled }
8384 onPress = { handlePress }
8485 style = { generatePinCodeContainerStyle ( isFocusedContainer , char ) }
85- testID = "otp-input"
86+ { ...buttonProps }
87+ testID = { buttonProps ?. testID ? `${ buttonProps . testID } ${ index } ` : `otp-input-${ index } ` }
88+ { ...( Platform . OS === "android" && {
89+ accessibilityLabel : buttonProps ?. testID
90+ ? `${ buttonProps . testID } ${ index } `
91+ : `otp-input-${ index } ` ,
92+ } ) }
8693 >
8794 { isFocusedInput && ! hideStick ? (
8895 < VerticalStick
@@ -93,7 +100,12 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
93100 ) : (
94101 < Text
95102 { ...textProps }
96- testID = { textProps ?. testID ? `${ textProps . testID } -${ index } ` : undefined }
103+ testID = { textProps ?. testID ? `${ textProps . testID } ${ index } ` : undefined }
104+ { ...( Platform . OS === "android" && {
105+ accessibilityLabel : textProps ?. testID
106+ ? `${ textProps . testID } ${ index } `
107+ : `otp-input-text-${ index } ` ,
108+ } ) }
97109 style = { [
98110 styles . codeText ,
99111 pinCodeTextStyle ,
@@ -120,6 +132,7 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
120132 aria-disabled = { disabled }
121133 editable = { ! disabled }
122134 testID = "otp-input-hidden"
135+ { ...( Platform . OS === "android" && { accessibilityLabel : "otp-input-hidden" } ) }
123136 onFocus = { handleFocus }
124137 onBlur = { handleBlur }
125138 caretHidden = { Platform . OS === "ios" }
0 commit comments