@@ -1068,6 +1068,18 @@ const emptyFunctionThatReturnsTrue = () => true;
10681068 *
10691069 */
10701070function InternalTextInput ( props : Props ) : React . Node {
1071+ const {
1072+ 'aria-busy' : ariaBusy ,
1073+ 'aria-checked' : ariaChecked ,
1074+ 'aria-disabled' : ariaDisabled ,
1075+ 'aria-expanded' : ariaExpanded ,
1076+ 'aria-selected' : ariaSelected ,
1077+ accessibilityState,
1078+ id,
1079+ tabIndex,
1080+ ...otherProps
1081+ } = props ;
1082+
10711083 const inputRef = useRef < null | React . ElementRef < HostComponent < mixed >>> ( null ) ;
10721084
10731085 // Android sends a "onTextChanged" event followed by a "onSelectionChanged" event, for
@@ -1388,24 +1400,33 @@ function InternalTextInput(props: Props): React.Node {
13881400 // so omitting onBlur and onFocus pressability handlers here.
13891401 const { onBlur , onFocus , ...eventHandlers } = usePressability ( config ) || { } ;
13901402
1391- const _accessibilityState = {
1392- busy : props [ 'aria-busy' ] ?? props . accessibilityState ?. busy ,
1393- checked : props [ 'aria-checked' ] ?? props . accessibilityState ?. checked ,
1394- disabled : props [ 'aria-disabled' ] ?? props . accessibilityState ?. disabled ,
1395- expanded : props [ 'aria-expanded' ] ?? props . accessibilityState ?. expanded ,
1396- selected : props [ 'aria-selected' ] ?? props . accessibilityState ?. selected ,
1397- } ;
1403+ let _accessibilityState ;
1404+ if (
1405+ accessibilityState != null ||
1406+ ariaBusy != null ||
1407+ ariaChecked != null ||
1408+ ariaDisabled != null ||
1409+ ariaExpanded != null ||
1410+ ariaSelected != null
1411+ ) {
1412+ _accessibilityState = {
1413+ busy : ariaBusy ?? accessibilityState ?. busy ,
1414+ checked : ariaChecked ?? accessibilityState ?. checked ,
1415+ disabled : ariaDisabled ?? accessibilityState ?. disabled ,
1416+ expanded : ariaExpanded ?? accessibilityState ?. expanded ,
1417+ selected : ariaSelected ?? accessibilityState ?. selected ,
1418+ } ;
1419+ }
1420+
1421+ let style = flattenStyle ( props . style ) ;
13981422
13991423 if ( Platform . OS === 'ios' ) {
14001424 const RCTTextInputView =
14011425 props . multiline === true
14021426 ? RCTMultilineTextInputView
14031427 : RCTSinglelineTextInputView ;
14041428
1405- const style =
1406- props . multiline === true
1407- ? StyleSheet . flatten ( [ styles . multilineInput , props . style ] )
1408- : props . style ;
1429+ style = props . multiline === true ? [ styles . multilineInput , style ] : style ;
14091430
14101431 const useOnChangeSync =
14111432 ( props . unstable_onChangeSync || props . unstable_onChangeTextSync ) &&
@@ -1415,15 +1436,16 @@ function InternalTextInput(props: Props): React.Node {
14151436 < RCTTextInputView
14161437 // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
14171438 ref = { ref }
1418- { ...props }
1439+ { ...otherProps }
14191440 { ...eventHandlers }
1420- accessible = { accessible }
14211441 accessibilityState = { _accessibilityState }
1442+ accessible = { accessible }
14221443 submitBehavior = { submitBehavior }
14231444 caretHidden = { caretHidden }
14241445 dataDetectorTypes = { props . dataDetectorTypes }
1425- focusable = { focusable }
1446+ focusable = { tabIndex !== undefined ? ! tabIndex : focusable }
14261447 mostRecentEventCount = { mostRecentEventCount }
1448+ nativeID = { id ?? props . nativeID }
14271449 onBlur = { _onBlur }
14281450 onKeyPressSync = { props . unstable_onKeyPressSync }
14291451 onChange = { _onChange }
@@ -1439,7 +1461,6 @@ function InternalTextInput(props: Props): React.Node {
14391461 />
14401462 ) ;
14411463 } else if ( Platform . OS === 'android' ) {
1442- const style = [ props . style ] ;
14431464 const autoCapitalize = props . autoCapitalize || 'sentences' ;
14441465 const _accessibilityLabelledBy =
14451466 props ?. [ 'aria-labelledby' ] ?? props ?. accessibilityLabelledBy ;
@@ -1466,18 +1487,19 @@ function InternalTextInput(props: Props): React.Node {
14661487 < AndroidTextInput
14671488 // $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
14681489 ref = { ref }
1469- { ...props }
1490+ { ...otherProps }
14701491 { ...eventHandlers }
1471- accessible = { accessible }
14721492 accessibilityState = { _accessibilityState }
14731493 accessibilityLabelledBy = { _accessibilityLabelledBy }
1494+ accessible = { accessible }
14741495 autoCapitalize = { autoCapitalize }
14751496 submitBehavior = { submitBehavior }
14761497 caretHidden = { caretHidden }
14771498 children = { children }
14781499 disableFullscreenUI = { props . disableFullscreenUI }
1479- focusable = { focusable }
1500+ focusable = { tabIndex !== undefined ? ! tabIndex : focusable }
14801501 mostRecentEventCount = { mostRecentEventCount }
1502+ nativeID = { id ?? props . nativeID }
14811503 numberOfLines = { props . rows ?? props . numberOfLines }
14821504 onBlur = { _onBlur }
14831505 onChange = { _onChange }
@@ -1606,11 +1628,12 @@ const ExportedForwardRef: React.AbstractComponent<
16061628 } ,
16071629 forwardedRef : ReactRefSetter < TextInputInstance > ,
16081630) {
1609- const style = flattenStyle ( restProps . style ) ;
1631+ let style = flattenStyle ( restProps . style ) ;
16101632
16111633 if ( style ?. verticalAlign != null ) {
16121634 style . textAlignVertical =
16131635 verticalAlignToTextAlignVerticalMap [ style . verticalAlign ] ;
1636+ delete style . verticalAlign ;
16141637 }
16151638
16161639 return (
@@ -1650,6 +1673,8 @@ const ExportedForwardRef: React.AbstractComponent<
16501673 ) ;
16511674} ) ;
16521675
1676+ ExportedForwardRef . displayName = 'TextInput' ;
1677+
16531678/**
16541679 * Switch to `deprecated-react-native-prop-types` for compatibility with future
16551680 * releases. This is deprecated and will be removed in the future.
0 commit comments