@@ -1068,6 +1068,18 @@ const emptyFunctionThatReturnsTrue = () => true;
1068
1068
*
1069
1069
*/
1070
1070
function 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
+
1071
1083
const inputRef = useRef < null | React . ElementRef < HostComponent < mixed >>> ( null ) ;
1072
1084
1073
1085
// Android sends a "onTextChanged" event followed by a "onSelectionChanged" event, for
@@ -1388,24 +1400,33 @@ function InternalTextInput(props: Props): React.Node {
1388
1400
// so omitting onBlur and onFocus pressability handlers here.
1389
1401
const { onBlur , onFocus , ...eventHandlers } = usePressability ( config ) || { } ;
1390
1402
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 ) ;
1398
1422
1399
1423
if ( Platform . OS === 'ios' ) {
1400
1424
const RCTTextInputView =
1401
1425
props . multiline === true
1402
1426
? RCTMultilineTextInputView
1403
1427
: RCTSinglelineTextInputView ;
1404
1428
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 ;
1409
1430
1410
1431
const useOnChangeSync =
1411
1432
( props . unstable_onChangeSync || props . unstable_onChangeTextSync ) &&
@@ -1415,15 +1436,16 @@ function InternalTextInput(props: Props): React.Node {
1415
1436
< RCTTextInputView
1416
1437
// $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1417
1438
ref = { ref }
1418
- { ...props }
1439
+ { ...otherProps }
1419
1440
{ ...eventHandlers }
1420
- accessible = { accessible }
1421
1441
accessibilityState = { _accessibilityState }
1442
+ accessible = { accessible }
1422
1443
submitBehavior = { submitBehavior }
1423
1444
caretHidden = { caretHidden }
1424
1445
dataDetectorTypes = { props . dataDetectorTypes }
1425
- focusable = { focusable }
1446
+ focusable = { tabIndex !== undefined ? ! tabIndex : focusable }
1426
1447
mostRecentEventCount = { mostRecentEventCount }
1448
+ nativeID = { id ?? props . nativeID }
1427
1449
onBlur = { _onBlur }
1428
1450
onKeyPressSync = { props . unstable_onKeyPressSync }
1429
1451
onChange = { _onChange }
@@ -1439,7 +1461,6 @@ function InternalTextInput(props: Props): React.Node {
1439
1461
/>
1440
1462
) ;
1441
1463
} else if ( Platform . OS === 'android' ) {
1442
- const style = [ props . style ] ;
1443
1464
const autoCapitalize = props . autoCapitalize || 'sentences' ;
1444
1465
const _accessibilityLabelledBy =
1445
1466
props ?. [ 'aria-labelledby' ] ?? props ?. accessibilityLabelledBy ;
@@ -1466,18 +1487,19 @@ function InternalTextInput(props: Props): React.Node {
1466
1487
< AndroidTextInput
1467
1488
// $FlowFixMe[incompatible-type] - Figure out imperative + forward refs.
1468
1489
ref = { ref }
1469
- { ...props }
1490
+ { ...otherProps }
1470
1491
{ ...eventHandlers }
1471
- accessible = { accessible }
1472
1492
accessibilityState = { _accessibilityState }
1473
1493
accessibilityLabelledBy = { _accessibilityLabelledBy }
1494
+ accessible = { accessible }
1474
1495
autoCapitalize = { autoCapitalize }
1475
1496
submitBehavior = { submitBehavior }
1476
1497
caretHidden = { caretHidden }
1477
1498
children = { children }
1478
1499
disableFullscreenUI = { props . disableFullscreenUI }
1479
- focusable = { focusable }
1500
+ focusable = { tabIndex !== undefined ? ! tabIndex : focusable }
1480
1501
mostRecentEventCount = { mostRecentEventCount }
1502
+ nativeID = { id ?? props . nativeID }
1481
1503
numberOfLines = { props . rows ?? props . numberOfLines }
1482
1504
onBlur = { _onBlur }
1483
1505
onChange = { _onChange }
@@ -1606,11 +1628,12 @@ const ExportedForwardRef: React.AbstractComponent<
1606
1628
} ,
1607
1629
forwardedRef : ReactRefSetter < TextInputInstance > ,
1608
1630
) {
1609
- const style = flattenStyle ( restProps . style ) ;
1631
+ let style = flattenStyle ( restProps . style ) ;
1610
1632
1611
1633
if ( style ?. verticalAlign != null ) {
1612
1634
style . textAlignVertical =
1613
1635
verticalAlignToTextAlignVerticalMap [ style . verticalAlign ] ;
1636
+ delete style . verticalAlign ;
1614
1637
}
1615
1638
1616
1639
return (
@@ -1650,6 +1673,8 @@ const ExportedForwardRef: React.AbstractComponent<
1650
1673
) ;
1651
1674
} ) ;
1652
1675
1676
+ ExportedForwardRef . displayName = 'TextInput' ;
1677
+
1653
1678
/**
1654
1679
* Switch to `deprecated-react-native-prop-types` for compatibility with future
1655
1680
* releases. This is deprecated and will be removed in the future.
0 commit comments