Commit Graph

392 Commits

Author SHA1 Message Date
XantreGodlike 4e45dce355 Typescript keyboard type fix (#35714)
Summary:
Made typescript typings for keyboardType correct

## Changelog

[INTERNAL] [FIXED] - Typescript typings for TextInput Keyboard type.
Url was placed in incorrect section, so I moved it to general type. Sorted keyboard types order as in React native docs.
![image](https://user-images.githubusercontent.com/57757211/209436128-beb7b872-b5fb-4122-8a82-11bff70f919d.png)
![image](https://user-images.githubusercontent.com/57757211/209436135-4453b398-1424-4e20-afea-40f54dbe88dc.png)

Pull Request resolved: https://github.com/facebook/react-native/pull/35714

Test Plan: I think this fix can be merged without tests, because of it shortness

Reviewed By: yungsters

Differential Revision: D42233193

Pulled By: robhogan

fbshipit-source-id: 11ce98c74aaf77e9cef733d6679d4f0a7fea259a
2022-12-28 06:42:54 -08:00
Sam Zhou ccefad049a Enable LTI in react-native
Summary: Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D41788271

fbshipit-source-id: 8e40dc3279ee0283b2845b9559a80862fdf59a17
2022-12-06 19:34:14 -08:00
Nicolas Gallagher 3681df2878 Add web compat unit tests and fixes (#35316)
Summary:
Adds compat with W3C logical CSS properties. See https://github.com/facebook/react-native/issues/34425

This is a replacement for reverted https://github.com/facebook/react-native/issues/34590, which can no longer be imported internally.

## Changelog

[General][Added] - Added CSS logical properties.

Pull Request resolved: https://github.com/facebook/react-native/pull/35316

Test Plan: Unit test snapshots.

Reviewed By: NickGerleman

Differential Revision: D41230978

Pulled By: necolas

fbshipit-source-id: 40e93d0d697f0cb28390480ce2b4bcbce18da70a
2022-11-17 10:58:38 -08:00
Tim Yung 666f56bff3 TextInput: Switch to useMergeRefs
Summary:
Switches `TextInput` from `setAndForwardRefs` to `useMergeRefs` (and `useCallback`).

Instead of creating a new `_setNativeRef` function on every render, this will now only create a new ref function when either `mostRecentEventCount` changes, `viewCommands` (i.e. `props.multiline` on iOS) changes, or when `props.forwardedRef` changes.

When a text input is being edited, `mostRecentEventCount` will probably change. But when an unfocused `TextInput` is being updated because a parent is being updated, we will now no longer unnecessarily create a new `ref`. The observable behavior of this is that any `ref` supplied onto `TextInput` will now be invoked less frequently.

Changelog:
[General][Changed] Any `ref` set on `TextInput` will now be updated less frequently (when the underlying `ref` has not changed).

Reviewed By: sammy-SC

Differential Revision: D41191439

fbshipit-source-id: c69a061317c51ad6c6ca8acd116539e0f24a1d08
2022-11-12 09:17:00 -08:00
Tim Yung 7bcc6f9b4d TextInput: Minimize Allocation of Imperative Functions
Summary:
While refactoring `TextInput`, I noticed that we are allocating each of the exported imperative instance methods on every invocation of the component. This is wasteful because if the `ref` does not change, this just creates more garbage.

Instead, we only need to allocate them when we are actually going to assign them onto a `ref`.

Changelog:
[Internal]

Reviewed By: sammy-SC

Differential Revision: D41191440

fbshipit-source-id: 0120d67a9e29a3e0c3f42c3fa436381d6bec7619
2022-11-12 09:17:00 -08:00
Tim Yung 93291213b0 TextInput: Refactor Flow Types for Instance
Summary:
Straightforward refactor of the instance exported by `TextInput`, to reduce duplication.

Changelog:
[Internal]

Reviewed By: christophpurrer

Differential Revision: D41191442

fbshipit-source-id: f7a623246640b5ac871d42d48ef88d30ad78ec3c
2022-11-12 09:17:00 -08:00
Tim Yung 744f633197 TextInput: Create ref Methods w/ Object.assign
Summary:
Straightforward refactor of how `TextInput` augments the exported `ref` with instance methods.

This change is in preparation for additional refactors to eliminate `setAndForwadRefs`.

Changelog:
[Internal]

Reviewed By: christophpurrer

Differential Revision: D41191441

fbshipit-source-id: 30560ce489c48409003a9f92875e5096d3f1130e
2022-11-12 09:17:00 -08:00
Luna Wei 114098d419 Back out "feat: mapped layout props for view component"
Summary:
Changelog: [Internal]

Original commit changeset: 870b9b58a740

Original Phabricator Diff: D41108750 (https://github.com/facebook/react-native/commit/cf3747957ab210e31504109bb6b3e34e773a5b9a)

Reviewed By: necolas, makovkastar

Differential Revision: D41145105

fbshipit-source-id: 8e525284d4d6d152fbcf053ec353d40dda3ee8d2
2022-11-08 20:37:27 -08:00
Mayank Sunil Pagar cf3747957a feat: mapped layout props for view component (#34590)
Summary:
This PR adds mapping for layout props, it maps

    marginInlineStart: 'marginStart',
    marginInlineEnd: 'marginEnd',
    marginBlockStart: 'marginTop',
    marginBlockEnd: 'marginBottom',
    marginBlock: 'marginVertical',
    marginInline: 'marginHorizontal',
    paddingInlineStart: 'paddingStart',
    paddingInlineEnd: 'paddingEnd',
    paddingBlockStart: 'paddingTop',
    paddingBlockEnd: 'paddingBottom',
    paddingBlock: 'paddingVertical',
    paddingInline: 'paddingHorizontal',

 as requested on https://github.com/facebook/react-native/issues/34425

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General][Added] - Added CSS logical properties by mapping layout props.

Pull Request resolved: https://github.com/facebook/react-native/pull/34590

Test Plan:
```js
<View
  style={[
    {
      marginBlockStart: 5,        // maps to "marginTop"
      borderWidth: 1,
      borderRadius: 5,
      padding: 5,
    }
  ]}>
  <Text style={{fontSize: 11}}>Hello World!</Text>
</View>
```

Reviewed By: cipolleschi

Differential Revision: D41108750

Pulled By: necolas

fbshipit-source-id: 870b9b58a740aba12290a0604a9f6b52aa52de4c
2022-11-08 12:53:41 -08:00
Gabriel Donadel Dall'Agnol b6869be1ac feat: Update TextInput inputMode to map "none" to showSoftInputOnFocus (#35228)
Summary:
This PR updates `inputMode` prop from the `TextInput` component to map the `none` option to `showSoftInputOnFocus={false}`  as suggested by necolas here -> https://github.com/facebook/react-native/pull/34460#issuecomment-1304837271. This change makes the inputMode API behaves a bit more similarly across platforms.

Related to https://github.com/necolas/react-native-web/issues/2421

## Changelog

[General] [Changed] -  Update TextInput inputMode to map "none" to showSoftInputOnFocus

## Test Plan

1. Open the RNTester app and navigate to the TextInput page
2. Test the `TextInput` component through the `Input modes` section

https://user-images.githubusercontent.com/11707729/200218435-6a33b319-e989-4086-aac3-506546982b38.mov

Pull Request resolved: https://github.com/facebook/react-native/pull/35228

Reviewed By: lunaleaps, necolas

Differential Revision: D41081876

Pulled By: jacdebug

fbshipit-source-id: cc634c3723647d8950bf2cfe67be70d0fbd488a6
2022-11-07 17:43:10 -08:00
Nick Gerleman 5d26ceaa23 Fixup TS Organization (#35169)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35169

This reorganizes typing structure a bit.

`Utilities.d.ts` was originally added for utilitiy types but I ended up leaving it a grab bag of types that didn't belong to any individual bit of code. Out of what is in it right now, `Insets` was actually public, and seems to have been imported.

We also run into files around the renderer which are [currently overwritten](https://github.com/facebook/react-native/commits/e286da25fc83324363486eb668806aca179f74b3/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts) by the React sync script.

Finally, all of the top-level imports of `Utilities` were auto-generated by VS Code, but fail in real apps. I think this is because our tsconfig sets a `baseUrl` to allow resolution from the types folder, so the tooling in the RN repo will use that, but it breaks in real apps that don't have that mapping.

This splits all these up into a couple separate directories that are hopefully easier to reason about, and removes `Omit` which has been a builtin type for quite some time (we were actually already using built-in `Omit`).

Changelog:
[General][Fixed] - Fixup TS Organization

Reviewed By: cipolleschi

Differential Revision: D40932319

fbshipit-source-id: 0b6e3e3eda603885b4dc01dcb9f5233aa546d128
2022-11-02 14:58:37 -07:00
Rick Hanlon b966d29724 Add back deprecated prop-types
Summary:
In 2017, React published v15.5 which extracted the built-in `prop types` to a separate package to reflect the fact that not everybody uses them. In 2018, React Native started to remove `PropTypes` from React Native for the same reason. In 0.68 React Native introduced a deprecation warning which notified users that the change was coming, and in 0.69 we removed the PropTypes entirely.

The feedback we've received from the community is that there has not been enough time to migrate libraries off of PropTypes. This has resulted in users needing to patch the React Native package `index.js` file directly to add back the PropTypes, instead of migrating off of them. We can empathize with this fix short term (it unblocks the upgrade) but long term this patch will cause users to miss important changes to `index.js`, and add a maintenance cost for users.

Part of the reason there was not enough time is that we didn't do a good job surfacing libraries that were using PropTypes. This means, when you got a deprecation warning, it wasn't clear where the source of the usage was (either in your code or in a library). So even if you wanted to migrate, it was difficult to know where to actually make the change.

In the next release, we've made it easier to find call sites using deprecated types by [fixing the code frame in errors](https://github.com/react-native-community/cli/pull/1699) reporting in LogBox, and ensuring that [the app doesn't crash without a warning](https://github.com/facebook/react-native/pull/34650). This should make it easier to identify exactly where the deprecated usage is, so you can migrate it.

To help users get off of the patch, and allow more time to migrate, we're walking back the removal of PropTypes, and keeping it as a deprecation for a couple more versions. We ask that you either migrate off PropTypes to a type system like TypeScript, or migrate to the `deprecated-react-native-prop-types` package.

Once we feel more confident that the community has migrated and will not need to patch React Native in order to fix this issue, we'll remove the PropTypes again. **If you have any trouble finding the source of the PropType usage, please file an issue so we can help track it down with you.**

Changelog:
[General][Changed] - Add back deprecated PropTypes

Reviewed By: yungsters

Differential Revision: D40725705

fbshipit-source-id: 8ce61be30343827efd6dc89a012eeef0b6676deb
2022-10-26 22:03:19 -07:00
Luna Wei fae770b9fe InputAccessoryView
Summary: Changelog: [Internal] Flow InputAccessoryView

Reviewed By: yungsters

Differential Revision: D39855166

fbshipit-source-id: 9c389854e6d76a0c0e881190cd1808088de324fd
2022-10-26 11:24:16 -07:00
Sam Zhou 466ba91657 Implicit instantiation codemod
Summary: Changelog: [Internal]

Reviewed By: bradzacher

Differential Revision: D40543059

fbshipit-source-id: 4d10671d8f2734b47d2aa86646be7f543a174515
2022-10-20 19:06:09 -07:00
bang9 048194849b feat(iOS): added lineBreakStrategy attribute to Text/TextInput (#31272)
Summary:
iOS did not support the implementation of Korean word-wrap(line-break) before iOS14.
If the attribute applied, the word-wrap of Korean will works.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Added] -  Line break strategy for Text and TextInput components

Pull Request resolved: https://github.com/facebook/react-native/pull/31272

Test Plan:
1. Test build and run on above iOS 14.
2. Test it does not affect existing text components when set default(none) strategy.
3. Test whether word-wrap works with Korean when set hangul-word strategy.

<img src="https://user-images.githubusercontent.com/26326015/112963967-d7f70c00-9182-11eb-9a34-8c758b80c219.png" width="300" height="" style="max-width:100%;">

Reviewed By: javache

Differential Revision: D39824809

Pulled By: lunaleaps

fbshipit-source-id: 42cb0385221a38c84e80d3494d1bfc1934ecf32b
2022-10-17 13:14:17 -07:00
Daksh Bhardwaj f353119113 feat : add aria labelled as alias for accessibilityLabelledBy (#34725)
Summary:
This adds the [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby)  prop to the components where it's used as requested on https://github.com/facebook/react-native/issues/34424,  equivalent [accessibilityLabelledBy](https://reactnative.dev/docs/accessibility#accessibilitylabelledby-android)

## Changelog
[General] [Added] - Add aria-modal prop to basic component

## TestPlan

 - Enable talkback.
 - Open the RNTester app and navigate to the Api's tab
 - Go to the TextInput with aria-labelledby attribute section

<img width="495" alt="Screenshot 2022-09-19 at 7 46 05 PM" src="https://user-images.githubusercontent.com/22423684/191038924-017dba93-ea7d-494d-ba6f-161e986f9b54.png">

Pull Request resolved: https://github.com/facebook/react-native/pull/34725

Reviewed By: lunaleaps

Differential Revision: D40176143

Pulled By: lunaleaps

fbshipit-source-id: 003d1ab27bfd01b5c6d4c58a4de501ec7966359d
2022-10-11 05:48:42 -07:00
Gabriel Donadel Dall'Agnol 32b6f319ba feat: Add support for verticalAlign style (#34567)
Summary:
This adds support for the `verticalAlign` style attribute, mapping the already existing `textAlignVertical` attribute as requested on https://github.com/facebook/react-native/issues/34425. This PR also updates the TextExample.android on the RNTester in order to facilitate the manual QA of this.

## Changelog

[Android] [Added] - Add support for verticalAlign style

Pull Request resolved: https://github.com/facebook/react-native/pull/34567

Test Plan:
1. On Android open the RNTester app and navigate to the Text page
2. Check the text alignment through the `Text alignment` section

https://user-images.githubusercontent.com/11707729/188051914-bf15f7eb-e53f-4de5-8033-d1b572352935.mov

Reviewed By: jacdebug

Differential Revision: D39771237

Pulled By: cipolleschi

fbshipit-source-id: d2a81bec1edd8d49a0fcd36a42fea53734909739
2022-10-03 05:57:30 -07:00
Tim Yung 494c47360f RN: Sort Imports via ESLint
Summary:
Applies the autofix from the newly introduced `lint/sort-imports` ESLint rule.

Changelog:
[Internal]

Reviewed By: cortinico, skinsshark

Differential Revision: D39907798

fbshipit-source-id: 17f5f11b08a5b4bb66286816b78eb26e07e829b8
2022-09-30 14:28:48 -07:00
Nick Gerleman 8cdc9e7f04 Place TypeScript Declarations Alongside Source Files
Summary:
React Native's TS definitions are currently mostly stored in one monolithic file. This change splits the definitions up to correspond to the source files they came from, and are placed next to the source files. I think this should help inform, and make it easy to update the TS declarations when touching the Flow file.

I noticed as part of the change that the typings have not yet removed many APIs that were removed from RN. This is bad, since it means using the removed/non-functional API doesn't cause typechecker errors. Locating typings next to source should prevent that from being able to happen.

The organization here means individual TS declarations can declare what will be in the RN entrypoint, which is a little confusing. Seems like a good potential next refactor, beyond the literal translation I did.

Changelog:
[General][Changed] - Place TS Declarations Alongside Source Files

Reviewed By: lunaleaps, rshest

Differential Revision: D39796598

fbshipit-source-id: b36366466fd1976bdd2d4c8f7a4104a33c457a07
2022-09-26 12:09:45 -07:00
Luna Wei 1cdeb20d54 TextInput
Summary: Changelog: [Internal] Add a flow type for TextInput

Reviewed By: yungsters

Differential Revision: D38883693

fbshipit-source-id: 798c1cfac55479420e683bd79d685a46c866c5d1
2022-09-15 17:06:17 -07:00
Rujin Cao b2ac528156 @emails -> @oncall (remaining ones)
Differential Revision: D39536169

fbshipit-source-id: 6c8d6787328eefecd23f3498b14a6d9ff750a670
2022-09-15 15:54:10 -07:00
Rubén Norte 699dabb2e3 Use findNodeHandle from RendererProxy instead of Paper in usages within the react-native package
Summary:
This replaces all direct references to `ReactNative` within the `react-native` package to use `findNodeHandle` with a reference obtained from `RendererProxy`, which will allow us to select the correct renderer.

Changelog: [internal]

Reviewed By: javache

Differential Revision: D39270689

fbshipit-source-id: a39875281ba7b7b1b00128564124b6adcacebc4d
2022-09-08 11:12:06 -07:00
Gabriel Donadel Dall'Agnol 73abcba40f feat: Unify TextInput autoComplete and textContentType props (#34523)
Summary:
This unifies the Android only  `autoComplete` and the iOS only `textContentType` TextInput props with the web `autoComplete` values as requested on https://github.com/facebook/react-native/issues/34424. I left the `textContentType` prop and the current supported `autoComplete` values untouched in order to avoid having a breaking change. This also updates RNTester to include test cases using the new `autoComplete` values

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Changed] - Unify TextInput autoComplete and textContentType props

Pull Request resolved: https://github.com/facebook/react-native/pull/34523

Test Plan:
1. Open the RNTester app and navigate to the TextInput page
2. Test the `TextInput` component through the `Text Auto Complete` section

https://user-images.githubusercontent.com/11707729/187118267-3b509631-7b84-47b7-a580-567a7f5b483f.mov

Reviewed By: NickGerleman

Differential Revision: D39104545

Pulled By: cipolleschi

fbshipit-source-id: a0d4b1b9ab336854a741a9efe4a62c3da0b5c0f4
2022-09-08 10:36:23 -07:00
ankit-tailor 98d84e571d Feat/accessibility state alias (#34524)
Summary:
This adds aliasing for accessibility state, it's used as requested on https://github.com/facebook/react-native/issues/34424.

- [aria-disabled](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled) to equivalent [accessibilityState.disabled](https://reactnative.dev/docs/accessibility#accessibilitystate)
- [aria-busy](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-busy) to equivalent [accessibilityState.busy](https://reactnative.dev/docs/accessibility#accessibilitystate)
- [aria-checked](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked) to equivalent [accessibilityState.checked](https://reactnative.dev/docs/accessibility#accessibilitystate)
- [aria-expanded](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded) to equivalent [accessibilityState.expanded](https://reactnative.dev/docs/accessibility#accessibilitystate)
- [aria-selected](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected) to equivalent [accessibilityState.selected](https://reactnative.dev/docs/accessibility#accessibilitystate)

## Changelog

[General] [Added] - Add aria-disabled, aria-busy, aria-checked, aria-expanded and aria-selected prop to core components

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

Pull Request resolved: https://github.com/facebook/react-native/pull/34524

Test Plan:
```js
<View
  aria-disabled={true}
  aria-selected={false}
  aria-checked={true}
  aria-expanded={true}
  aria-busy={true}
  style={{backgroundColor: '#527FE4', padding: 5}}>
  <Text style={{fontSize: 11}}>Blue background</Text>
</View>
```

Reviewed By: cipolleschi

Differential Revision: D39137790

Pulled By: jacdebug

fbshipit-source-id: 27b5c56e91731ba36bb4754d9862286a7a8191bc
2022-09-08 03:38:39 -07:00
Gabriel Donadel Dall'Agnol 9fac88574e feat: Add inputMode prop to TextInput component (#34460)
Summary:
This adds the `inputMode` prop to the TextInput component as requested on https://github.com/facebook/react-native/issues/34424, mapping web [inputMode types](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode) to equivalent [keyboardType](https://reactnative.dev/docs/textinput#keyboardtype) values.  This PR also updates RNTester TextInputExample in order to facilitate the manual QA.

### Caveats

~~This only adds support to `text`, `decimal`, `numeric`, `tel`, `search`, `email`, and `url` types.~~

#### `inputMode="none"`

**Currently mapped to `default` keyboard type.**

The main problem with this input mode is that it's not supported natively neither on Android or iOS. Android `TextView` does accept `none` as `android:inputType` but that makes the text not editable, which wouldn't really solve our problem. `UITextInput` on iOS on the other hand doesn't even have something similar to avoid displaying the virtual keyboard.

If we really want to add the support for `inputMode="none"` one interesting approach we could take is to do something similar to what WebKit has done (https://github.com/WebKit/WebKit/commit/3b5f0c8ecf9de23f79524ed02e290837ab8334cd). In order to achieve this behavior, they had to return a `UIView` with a bounds of `CGRectZero` as the inputView of the `WKContentView` when inputmode=none is present.
~~I guess the real question here should be, do we really want to add this? Or perhaps should we just map `inputMode="none"` to `keyboardType="default"`~~

Android docs: https://developer.android.com/reference/android/widget/TextView#attr_android:inputType
iOS docs: https://developer.apple.com/documentation/uikit/uikeyboardtype?language=objc

#### `inputMode="search"` on Android

**Currently mapped to `default` keyboard type.**

 Android `TextView` does not offers any options like `UIKeyboardTypeWebSearch` on iOS to be used  as `search` with `android:inputType` and that's probably the reason why `keyboardType="web-search"` is iOS only. I checked how this is handled on the browser on my Android device and it seems that Chrome just uses the default keyboard, maybe we should do the same?

### Open questions

- ~~What should be done about `inputMode="none"`?~~ Add it and map it to `default` keyboard type.
- ~~Which keyboard should we show on Android when `inputMode="search"`?~~ Use the `default` keyboard the same way Chrome does

## Changelog

[General] [Added] - Add inputMode prop to TextInput component

## Test Plan

1. Open the RNTester app and navigate to the TextInput page
2. Test the `TextInput` component through the `Input modes` section

https://user-images.githubusercontent.com/11707729/185691224-3042e828-a008-4bd0-bb3d-010a6a18dfd5.mov

Pull Request resolved: https://github.com/facebook/react-native/pull/34460

Reviewed By: necolas

Differential Revision: D38900724

Pulled By: cipolleschi

fbshipit-source-id: 60d405ccdbfad588b272fbb6b220b64ffdfc4b14
2022-08-30 08:19:51 -07:00
Daksh Bhardwaj 8c882b4f3d feat: added enterKeyHint prop to textInput (#34482)
Summary:
This adds the `enterKeyHint` prop to the TextInput component as requested on https://github.com/facebook/react-native/issues/34424, mapping web [enterKeyHint types](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint) to equivalent [returnKeyType](https://reactnative.dev/docs/textinput#returnkeytype) values. This PR also updates RNTester TextInputExample in order to facilitate the manual QA.

## Open questions
 - What should be the `returnType` in the case of `previous` in iOS?

 - what should happen if `enterKeyHint` and `returnKeyType` props are passed together?

## Changelog
[General] [Added] - Add enterKeyHint prop to TextInput component

Pull Request resolved: https://github.com/facebook/react-native/pull/34482

Test Plan:
- Open the RNTester app and navigate to the TextInput page
 - Test the TextInput component through the `enterKeyHint modes section`

 <image src="https://user-images.githubusercontent.com/22423684/186191205-9c04732e-568c-4cce-9564-50a84d70dca3.png" height="600px" width="300px" />

Reviewed By: GijsWeterings

Differential Revision: D38957275

Pulled By: necolas

fbshipit-source-id: d75f2c2000df5d9606a005083b20bf3a23b48831
2022-08-29 18:14:55 -07:00
Gabriel Donadel Dall'Agnol 49c9ccd3f8 feat: Add rows prop to TextInput component (#34488)
Summary:
This adds the Android only `rows` prop to TextInput as requested on https://github.com/facebook/react-native/issues/34424 mapping the existing `numberOfLines` prop to `rows`. This PR also updates the TextInputExample.android on the RNTester in order to facilitate the manual QA of this.

## Changelog

[Android] [Added] - Add rows prop to TextInput component

Pull Request resolved: https://github.com/facebook/react-native/pull/34488

Test Plan:
1. On Android open the RNTester app and navigate to the TextInput page
2. Test the `TextInput` component through the `Fixed number of lines` section

https://user-images.githubusercontent.com/11707729/186300173-7de79799-25b8-48af-99c0-8e3abeae334f.mov

Reviewed By: christophpurrer

Differential Revision: D38981953

Pulled By: cipolleschi

fbshipit-source-id: d4d84b3c0dac7342ba9a65e2491928fbc61ff4f1
2022-08-25 15:54:32 -07:00
Gabriel Donadel Dall'Agnol de75a7a22e feat: Add readOnly prop to TextInput component (#34444)
Summary:
This adds the `readOnly` prop to  TextInput as requested on https://github.com/facebook/react-native/issues/34424 mapping the existing `editable` prop to `readOnly` so that `readOnly={false}` maps to `editable={true}` and `readOnly={true}` represents ` editable={false}`. This PR also updates the TextInputExample on the RNTest in order to facilitate the manual QA of this.

## Changelog

[General] [Added] - Add readOnly prop to TextInput component

Pull Request resolved: https://github.com/facebook/react-native/pull/34444

Test Plan:
1. Open the RNTester app and navigate to the TextInput page
2. Test the `TextInput` component through the `Editable and Read only` section

https://user-images.githubusercontent.com/11707729/185295132-036443c8-1d5e-4567-a15e-5f1173cb0526.mov

Reviewed By: lunaleaps

Differential Revision: D38912786

Pulled By: necolas

fbshipit-source-id: faeb59ed8695732be682ec55406a2de0cb7e619a
2022-08-23 18:50:51 -07:00
Tony Du 1e3cb91707 Allow multiline TextInputs be submittable without blurring (#33653)
Summary:
For multiline TextInputs, it's possible to send the submit event when pressing the return key only with `blurOnSubmit`. However, there's currently no way to do so without blurring the input and dismissing the keyboard. This problem is apparent when we want to use a TextInput to span multiple lines but still have it be submittable (but not blurrable), like one might want for a TODO list.

![multiline-momentary-blur](https://user-images.githubusercontent.com/22553678/163596940-aae779f5-4d2a-4425-8ed0-e4aa77b90699.gif)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Added] - Add `returnKeyAction` prop to `TextInput` component
[General] [Deprecated] - Remove usages of `blurOnSubmit` in native code and convert `blurOnSubmit` to `returnKeyAction` in the JavaScript conversion layer

Pull Request resolved: https://github.com/facebook/react-native/pull/33653

Test Plan:
Verified old usages of combinations of `blurOnSubmit` and `multiline` matched previous behavior and that the new `returnKeyAction` prop behaves as expected.

| Android | iOS |
| --- | -- |
| ![android-returnkeyaction-test](https://user-images.githubusercontent.com/22553678/163597864-2e306f98-7b6e-4ddf-8a35-625d397d3dce.gif) | ![ios-returnkeyaction-test](https://user-images.githubusercontent.com/22553678/163598407-9e059f74-3549-4b46-8e03-c19bfaa6dd3d.gif)  |

With the changes, the TODO list example from before now looks like this:

![multiline-no-momentary-blur](https://user-images.githubusercontent.com/22553678/163598810-f3a71d62-5514-486e-bf6a-79169fe86378.gif)

Reviewed By: yungsters

Differential Revision: D35735249

Pulled By: makovkastar

fbshipit-source-id: 1f2237a2a5e11dd141165d7568c91c9824bd6f25
2022-07-22 13:08:45 -07:00
Garrett Forbes Monroe 191eb62edb Revert D37801394: Multisect successfully blamed D37801394 for test or build failures
Summary:
This diff is reverting D37801394 (https://github.com/facebook/react-native/commit/51f49ca9982f24de08f5a5654a5210e547bb5b86)
D37801394 (https://github.com/facebook/react-native/commit/51f49ca9982f24de08f5a5654a5210e547bb5b86) has been identified to be causing the following test or build failures:
Tests affected:
- https://www.internalfb.com/intern/test/844424989736255/

Here's the Multisect link:
https://www.internalfb.com/intern/testinfra/multisect/1062919
Here are the tasks that are relevant to this breakage:
T116036972: 105 tests started failing for oncall bridgeless_jest_e2e_tests in the last 2 weeks
We're generating a revert to back out the changes in this diff, please note the backout may land if someone accepts it.

**To Address Land blocker from previous version (see pic):**
{F752642767}

```
Changelog:
[General][Change] - Revert breaking change in MPay order creation screen (user input in duplicated, and then not deletable. See T126127801 for more details)
```

Reviewed By: philIip

Differential Revision: D37863306

fbshipit-source-id: 24f2448d7bc9761ec31edd6f6b97c668171027d3
2022-07-15 08:20:20 -07:00
George Zahariev f392ba6725 Codemod {...null} to {} in xplat/js
Summary:
Now that [exact_empty_objects has been enabled](https://fb.workplace.com/groups/flowlang/posts/1092665251339137), we can codemod `{...null}` to `{}` - they are now equivalent.

1) Run my one-off jscodeshift codemod
2) `scripts/flow/tool update-suppressions .` (as some suppressions move around due to the change)

drop-conflicts

Reviewed By: bradzacher

Differential Revision: D37834078

fbshipit-source-id: 6bf4913910e5597e5dd9d5161cd35deece6a7581
2022-07-14 17:00:28 -07:00
Nick Gerleman 51f49ca998 Fix TextInput dropping text when used as uncontrolled component with defaultValue
Summary:
A layout-impacting style change will trigger a layout effect hook within `TextInput`. This hook fires a ViewManager command to set the text input based on the known JS value: https://github.com/facebook/react-native/blob/d82cd3cbce1597512bb2868fde49b5b3850892a0/Libraries/Components/TextInput/TextInput.js#L1009

The JS value is determined using `value` if set, falling back to `defaultValue`. If a component uses `TextInput` as an uncontrolled component, and does not set this value, the command wipes text input back to the default value. This does not happen on re-render of the JS side, despite setting text prop, since the underlying native property never changes/triggers a rerender.

This change alters the logic to prefer `lastNativeText` instead of `defaultValue` when available, to retain the updated `TextInput` content on relayout.

Reviewed By: javache

Differential Revision: D37801394

fbshipit-source-id: d56c719d56bebac64553c731ce9fca8efc7feae9
2022-07-13 16:41:17 -07:00
hduprat afa5df1764 - Fix InputAccessoryView crash on Android (#33803)
Summary:
`InputAccessoryView` works fine on iOS, but crashes on Android - you can see that by using an Android device on the [Expo Snack from the official doc](https://reactnative.dev/docs/inputaccessoryview).
It forces the developer not to render the component on Android, which is usually good, but other components have implemented other, safer ways to deal with incompatibility issues.

I am of course open to discussion about this change, as well as other implementation ideas.

## Changelog

[Android] [Fixed] - Fix InputAccessoryView crash on Android

Pull Request resolved: https://github.com/facebook/react-native/pull/33803

Test Plan:
`yarn test` gives out the following output:
![image](https://user-images.githubusercontent.com/3397791/167677057-3fda5b53-78bf-4bab-976f-c2e624f4a264.png)

Reviewed By: cipolleschi

Differential Revision: D37215394

Pulled By: cortinico

fbshipit-source-id: 66c4401f7c61b745ea893969d69c8dde3e5afb03
2022-06-28 06:13:47 -07:00
Hetan Thakkar 2fb107c9a6 Fixed Textinput not properly handling padding and paddingVertical in style props (#33564)
Summary:
Fixes https://github.com/facebook/react-native/issues/33562 #21720. Earlier this [`paddingTop`](https://github.com/facebook/react-native/blob/d5da70e17e8c8210cd79a4d7b09c6a5ded4b5607/Libraries/Components/TextInput/TextInput.js#L1367) used to override the  `paddingTop` of `padding` and `paddingVertical` of the style props. Using `Stylesheet.flatten` will solve this problem.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fixed paddingTop not being applied when using padding and paddingVertical in multiline textinput

Pull Request resolved: https://github.com/facebook/react-native/pull/33564

Reviewed By: christophpurrer, cortinico

Differential Revision: D36018667

Pulled By: kacieb

fbshipit-source-id: 0af0ed8ea536ec4e813325b1cf93c7cb2481eb07
2022-05-17 03:26:34 -07:00
Christian Ruink f2e23215ca Adding missing prop for RN Android TextInput behavior
Summary:
An issue that popped up working on:
D36140890
There is already behavior implemented to set the TextInput caret/cursor color independently from the selection box color in Android.
However this handy prop, was not documented or added as one of the available props for the TextInput component.

Associated behavior can be found here:
https://www.internalfb.com/code/fbsource/[f116d651b2e8]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java?lines=512

## **Changelog**
[Android] - Add android-only prop documentation at the TextInput js level.

Reviewed By: genkikondo

Differential Revision: D36208656

fbshipit-source-id: a54a2646351d897e0d598d5e1979f2a0c443e9d6
2022-05-10 16:48:20 -07:00
George Zahariev 20d9d3aa6a Fixes to non-product code (e.g React Native)
Summary:
We are working on making the empty object literal `{}` have the type `{}` - i.e. exact empty object - rather than being unsealed.

Some manual fixes, in particular to React Native code, which is used and can be synced to other repos (e.g. WWW).

With these changes, error diff in Xplat is down to ~1990 errors

Note that after I roll out `exact_empty_objects`, I'll codemod all the `{...null}` (the only way to get an exact empty object currently) back to `{}`

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D36142838

fbshipit-source-id: 054caf370db230f42a4c5f5706c88979ef246537
2022-05-04 16:13:07 -07:00
Rick Hanlon 41cbccd98d @nocommit React Native sync for revisions 1159ff6...34aa5cf
Summary:
I'm kicking this off to see what's the extent of failures we're going to get if we try to bump to React 18 inside RN OSS.

This sync includes the following changes:
- **[34aa5cfe0](https://github.com/facebook/react/commit/34aa5cfe0 )**: Update local package.jsons for 18 //<Andrew Clark>//
- **[e7d0053e6](https://github.com/facebook/react/commit/e7d0053e6 )**: [fizz] Fix validateIterable call ([#24166](https://github.com/facebook/react/pull/24166)) //<salazarm>//
- **[6b85823b3](https://github.com/facebook/react/commit/6b85823b3 )**: Clean up Selective Hydration / Event Replay flag ([#24156](https://github.com/facebook/react/pull/24156)) //<salazarm>//

Changelog:
[General][Changed] - React Native sync for revisions 1159ff6...34aa5cf

jest_e2e[run_all_tests]

Reviewed By: cortinico

Differential Revision: D35504622

fbshipit-source-id: ad0f6b42b6e03d78cd5d6ba51ce5a5730d25b167
2022-04-12 08:50:06 -07:00
Vojtech Novak 8a5460ce80 fix attempting to focus disabled textinputs (#30695)
Summary:
when we call `focus()` upon a TextInput ref which has prop `editable=false` it marks the textinput as focused in `TextInputState` even though the focus is rejected by textinput itself because it is not editable.

then, when you change `editable` prop to `true` and call `focus` again, [this condition](https://github.com/facebook/react-native/blob/e912c462eb0b7166ca5947bb5a3ee20761d910b6/Libraries/Components/TextInput/TextInputState.js#L46) or rather [this one](https://github.com/facebook/react-native/blob/1b2b2198e1b2383523b4655dc8c220d251b057d6/Libraries/Components/TextInput/TextInputState.js#L89) will evaluate to `false` and focus will not happen even though it can and should happen.

see also https://github.com/facebook/react-native/blob/0.64-stable/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js#L3895

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - `focus()` on TextInput to respect its `editable` state

Pull Request resolved: https://github.com/facebook/react-native/pull/30695

Test Plan: Create a `TextInput` with prop `editable=false` and call `ref.current.focus()` upon its ref. TextInput should not be marked as focused in `TextInputState`.

Reviewed By: yungsters

Differential Revision: D34357913

Pulled By: lunaleaps

fbshipit-source-id: 9a2fb819bbb05ef213c9b5d739dec583ae0a3e6f
2022-03-22 11:43:57 -07:00
Ramanpreet Nara 5c8d95b4e2 Make remaining FBiOS/FB4A components export SVCs via __INTERNAL_VIEW_CONFIG
Summary:
The static ViewConfig codegen generates the static ViewConfig inside the JavaScript module [under an exported constant](https://github.com/facebook/react-native/blob/a0a2958cdac767f50084c2d5bee6cf224ffb9db3/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js#L127-L129):

```
export const __INTERNAL_VIEW_CONFIG = VIEW_CONFIG;
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
```

This exported constant allows us to build a test page that requires all components, and compares their static ViewConfigs with their native ViewConfig.

This diff makes components with hand-written static ViewConfigs also export this __INTERNAL_VIEW_CONFIG const.

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D34541868

fbshipit-source-id: f55dd3f1b161038baaf84cbbf75c1f4041c34647
2022-03-01 16:27:52 -08:00
Moti Zilberman 1814bffcc2 Minor changes to Flow types
Summary: Changelog: [Internal]

Reviewed By: arushikesarwani94

Differential Revision: D34171528

fbshipit-source-id: c3fdc4a8c77731f1f43f0e6d830d172906ed79a1
2022-02-15 08:50:55 -08:00
Ramanpreet Nara 971ba5c26b Re-introduce {eventName}: true ViewConfig ValidAttributes in Static ViewConfigs
Summary:
# Problem
I removed the {eventName}: true entries from ViewConfigs validAttributes in D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a). These entries were iOS-only. I removed them to achieve platform-consistency in native ViewConfigs.

This change broke the onLayout event for all React Native components. So, I reverted D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for native ViewConfigs server-side. But I never got around to reverting D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for static ViewConfigs.

# Changes
This diff reverts D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for Static ViewConfigs, with server-side gating.

Now, these {eventName}: true ViewConfig validAttribute will be inserted into all view configs (static and native) **by default**.

Calling RCTDisableViewConfigEventValidAttributes(YES) on iOS will remove {eventName}: true ViewConfig ValidAttributes entries from Static ViewConfigs. (Previously, this method only removed the entries from native ViewConfigs).

https://www.internalfb.com/code/fbsource/[6615b0675bdf]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=344

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D33933403

fbshipit-source-id: 17823ed99f97d7851f04e5cdab9c95667df13253
2022-02-08 19:11:08 -08:00
Tim Yung 3e229f27bc RN: Remove propTypes from Image, Text, and TextInput
Summary:
Removes the `propTypes` member from the `Image`, `Text`, and `TextInput` components.

They have been deprecated since React Native v0.66.

Changelog:
[General][Removed] - Removed `Image.propTypes`, `Text.propTypes`, and `TextInput.propTypes`.

Reviewed By: kacieb

Differential Revision: D33750298

fbshipit-source-id: 085f83ad838196bdd531b097b8ce5957270c3ad1
2022-02-01 16:19:01 -08:00
Ramanpreet Nara 067bcb5325 Fix SVC for RCT{Multiline,Singleline}TextInput
Summary:
See title.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33341775

fbshipit-source-id: be1c876375b1106d51e871805c23d345906b4631
2022-01-11 14:22:14 -08:00
Ramanpreet Nara 8487470476 Fix SVC for AndroidTextInput
Summary:
## SVC != NVC Failure
```
 LOG  SVC AndroidTextInput Invalid
 LOG  {
  "missing": {
    "validAttributes": {
      "borderBottomLeftRadius": true,
      "borderBottomColor": {
        "process": "[Function processColor]"
      },
      "borderRightColor": {
        "process": "[Function processColor]"
      },
      "borderLeftColor": {
        "process": "[Function processColor]"
      },
      "borderTopRightRadius": true,
      "borderColor": {
        "process": "[Function processColor]"
      },
      "borderBottomRightRadius": true,
      "borderRadius": true,
      "borderStyle": true,
      "borderTopColor": {
        "process": "[Function processColor]"
      },
      "borderTopLeftRadius": true
    }
  },
  "unexpected": {
    "validAttributes": {
      "autoCompleteType": true
    }
  },
  "unequal": []
}
```

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33341773

fbshipit-source-id: a3c7f043d6b2ba0e2a4253739826e6f7f68e7ca5
2022-01-11 00:24:41 -08:00
Ramanpreet Nara cb3321e3b0 Refactor: Inline AndroidTextInputViewConfig
Summary:
Putting the static view config into its own file creates the uncertainty that n > 1 files import the static view config. This isn't true for AndroidTextViewConfig. So, let's just inline this static view config in the NativeComponent that uses it.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33341776

fbshipit-source-id: 6fb710b8776d7b9276022c5226acefd7cf8395fb
2022-01-11 00:24:41 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Samuel Susla 8c6a98400e Introduce TextInput.onChangeSync
Summary:
changelog: [internal]

Add experimental `TextInput.onChangeSync` which delivers onChange event synchronously.

Reviewed By: ShikaSD

Differential Revision: D33188083

fbshipit-source-id: 1e1dcd0d71c7eec98d3d5f69967659e07ac4e6a6
2021-12-30 06:38:50 -08:00
Samuel Susla f5f6fd70f2 Introduce TextInput.onKeyPressSync
Summary:
changelog: [internal]

Introduce a way to execute `onKeyPress` synchronously. This feature is experimental and will be changed in the future. It is not decided if marking native events as "sync" is going to be path forward with synchronous access.

NOTE: This is experimental API.

Reviewed By: ShikaSD

Differential Revision: D32882092

fbshipit-source-id: 68c66a9bb7c97758219e085c88a77f3c475c1eb3
2021-12-07 13:42:18 -08:00
Liron Yahdav 771ca921b5 Add TextInput.setSelection method
Summary:
Adds a `setSelection` imperative method to `TextInput`.

Changelog:
[General][Added] - Adds a setSelection imperative method to TextInput

Reviewed By: JoshuaGross

Differential Revision: D32186514

fbshipit-source-id: 549a7d93b1c55363cf01d804b1e3d735e55c4481
2021-12-03 11:54:01 -08:00
Marcel Lasaj 9eb0881c8f fix(android): Updated TextInput prop types to accomodate for new autoComplete values (#32575)
Summary:
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
This fixes the "Failed prop type: Invalid prop `autoComplete` of value `[any-of-the-new-values]`" warning, as mentioned in https://github.com/facebook/react-native/issues/32557.

[This commit](https://github.com/facebook/react-native/commit/d9e0ea77f0111fd8400c65d68e45d54e2f84287b) introduced new HintConstants for autofill, but added those only to [`TextInput.js`](https://github.com/facebook/react-native/blob/main/Libraries/Components/TextInput/TextInput.js#L331) and forgot to add them (and the new docs' description) to either [`AndroidTextInputNativeComponent`](https://github.com/facebook/react-native/blob/main/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js#L99) or [`DeprecatedTextInputPropTypes.js`](https://github.com/facebook/react-native/blob/main/Libraries/DeprecatedPropTypes/DeprecatedTextInputPropTypes.js#L67). I know, the latter has clearly been deprecated, but until it is actually being removed, it shouldn't throw warnings like that.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Updated TextInput prop types to accomodate for new autoComplete values

Pull Request resolved: https://github.com/facebook/react-native/pull/32575

Test Plan: There is no warning after these changes.

Reviewed By: yungsters

Differential Revision: D32324108

Pulled By: lunaleaps

fbshipit-source-id: df27cbbd54788f26471029c9201c6a27ca8b7893
2021-11-11 15:41:44 -08:00