Commit Graph

2040 Commits

Author SHA1 Message Date
Xin Chen 89ef5bd6f9 Add TraceUpdateOverlay to RN AppContainer
Summary:
This diff adds `TraceUpdateOverlay` native component to RN `AppContainer.js`. This will enable the overlay when the build is in DEV environment and the DevTools global hook exists. It also closed gap between the JS dev mode and native dev support flag, so that the native component will be available when used by JS.

## Update (2/13/2023)
Instead of the original approach where I put a default value to the devsupport manager flag, I did ui manager check from JS and make sure the native component exists before using it. This is cleaner.

## Problem
Since the `AppContainer` is being used by all RN apps, we need to make sure the native component is registered in UI Manager of the RN app when it's used. Currently, the native component lives in the `DebugCorePackage.java`, which is added to the RN app [when the `DevSupportManager` is used](https://fburl.com/code/muqmqbsa). However, there's no way to tell if an app is using dev support manager in JS, hence there are gaps when the JS code uses `TraceUpdateOverlay`, vs when the native code registered the native component. This issue caused test error in [ReactNativePerfTest](https://fburl.com/testinfra/j24wzh46) from the [previous diff](https://fburl.com/diff/bv9ckhm7), and it actually prevents Flipper from running this properly as shown in this video:

https://pxl.cl/2sqKf

The errors shown in Flipper indicates the RN surface from the plugin is also missing `TraceUpdateOverlay` in its UI Manager:

{F869168865}

## Solution
To fix this issue, we should find a way to expose if the app is using dev support manager in JS. Or we should set to use DevSupportManager whenever it's a dev build as claimed in JS. I will try to find some way to achieve either one of this. I am open to suggestions here for where I should add the native component to. Given that it's used in the AppContainer, and any app could be built in development mode, I don't want to make people to manually add this native component themselves.

## Alternatives
There are some other approaches that could mitigate the issue, but less ideal:

For the test issue
1) Add `setUseDeveloperSupport(true)` to [ReactNativeTestRule.java](https://fburl.com/code/7jaoamdp). That will make the related test pass by using the DevSupportPackages, which has the native component. However, it only fixes tests using that class.

2) Override the package for [ReactNativeTestRule.java](https://fburl.com/code/b4em32fa), or `addPackage` with more packages including the native component. Again this only fixes this test.

3) Add the native component to the [`MainReactPackage`](https://fburl.com/code/nlayho86), which is what I did here in this diff. This would fix more cases as this package is [recommended to be used](https://fburl.com/code/53eweuoh) for all RN app. However, it may not fix all the cases if the RN app didn't manually use it.

4) Add the native component in the [`CoreModulesPackage`](https://fburl.com/code/lfeklztl), which will make all RN apps work, but at the cost of increase package size when this feature is not needed. Or, we could argue that we want to have highlights on trace updates for production build as well?

Changelog:
[Internal] - Enable TraceUpdateOverlay to RN AppContainer

Reviewed By: rubennorte

Differential Revision: D43180893

fbshipit-source-id: a1530cc6e2a9d8c905bdfe5d622d85c4712266f8
2023-02-14 22:32:55 -08:00
Xin Chen 6ac88a4378 Add TraceUpdateOverlay native component to render highlights on trace updates
Summary:
This diff adds `TraceUpdateOverlay` native component to render highlights when trace update is detected from React JS. This allows a highlight border to be rendered outside of the component with re-renders.

- Created `TraceUpdateOverlay` native component and added to the `DebugCorePackage`
- Added to C++ registry so it's compatible with Fabric
- Added to `AppContainer` for all RN apps when global devtools hook is available

Changelog:
[Android][Internal] - Add trace update overlay to show re-render highlights

Reviewed By: javache

Differential Revision: D42831719

fbshipit-source-id: 30c2e24859a316c27700270087a0d7779d7ad8ed
2023-02-13 21:55:33 -08:00
bigcupcoffee 23607aea68 Fix incorrect touchable hitSlop and pressRetentionOffset type (#36065)
Summary:
Incorrect TS type disallows use of `hitSlop={number}`. Fixed by using Pressable's hitSlop type.

NOTE: I did not bother to change Flow types in the `.js` file, please add a commit doing that if required.

## Changelog
[GENERAL] [FIXED] - Fix touchable hitSlop type

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

Test Plan: None needed

Reviewed By: christophpurrer

Differential Revision: D43117689

Pulled By: javache

fbshipit-source-id: 96e5ae650f47382c8d7fa1ddf63c76461c65dcc7
2023-02-09 03:05:23 -08:00
gabrieldonadel 597a1ff60b feat: Add logical border block color properties (#35999)
Summary:
This PR implements logical border block color properties as requested on https://github.com/facebook/react-native/issues/34425. This implementation includes the addition of the following style properties

- `borderBlockColor`, equivalent to `borderTopColor` and `borderBottomColor`.
- `borderBlockEndColor`, equivalent to `borderBottomColor`.
- `borderBlockStartColor`, equivalent to `borderTopColor`.

## Changelog

[GENERAL] [ADDED] - Add logical border block color properties

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

Test Plan:
1. Open the RNTester app and navigate to the `View` page
2. Test the new style properties through the `Logical Border Color` section

<table>
<tr>
    <td>Android</td>
    <td>iOS</td>
</tr>
  <tr>
    <td><video src="https://user-images.githubusercontent.com/11707729/215384882-5b96518e-ad70-4157-a7f3-130f488cc41c.mov"  alt="1" width="360px"   />
    </td>
<td>
<video src="https://user-images.githubusercontent.com/11707729/215392728-cfc6a097-26c1-4ffe-ab0e-f0a5a71a902d.mov"2" width="360px"  />
</td>
   </tr>
</table>

Reviewed By: cipolleschi

Differential Revision: D42849911

Pulled By: jacdebug

fbshipit-source-id: 822cff5264689c42031d496105537032b5cd31ef
2023-01-31 10:58:24 -08:00
Sebastian Silbermann fac7859863 Add TextInput's inputMode TypeScript types (#35987)
Summary:
Forward-porting https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64100/

## Changelog

[GENERAL] [FIXED] - Add `TextInput`'s `inputMode` TypeScript types

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

Test Plan: - [x] https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64100/ green

Reviewed By: christophpurrer

Differential Revision: D42799862

Pulled By: jacdebug

fbshipit-source-id: b387fd8bc53e66d6125fee810862de3e292e6e74
2023-01-27 08:35:51 -08:00
Janic Duplessis c19548728c Add maintainVisibleContentPosition support on Android (#35049)
Summary:
This adds support for `maintainVisibleContentPosition` on Android. The implementation is heavily inspired from iOS, it works by finding the first visible view and its frame before views are update, then adjusting the scroll position once the views are updated.

Most of the logic is abstracted away in MaintainVisibleScrollPositionHelper to be used in both vertical and horizontal scrollview implementations.

Note that this only works for the old architecture, I have a follow up ready to add fabric support.

## 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
-->

[Android] [Added] - Add maintainVisibleContentPosition support on Android

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

Test Plan:
Test in RN tester example on Android

https://user-images.githubusercontent.com/2677334/197319855-d81ced33-a80b-495f-a688-4106fc699f3c.mov

Reviewed By: ryancat

Differential Revision: D40642469

Pulled By: skinsshark

fbshipit-source-id: d60f3e2d0613d21af5f150ca0d099beeac6feb91
2023-01-23 12:00:05 -08:00
Dimitar Nestorov e162b07982 Add accessibilityLabelledBy TypeScript type (#35883)
Summary:
`accessibilityLabelledBy` is missing from `AccessibilityPropsAndroid` TypeScript interface

## Changelog

[GENERAL] [FIXED] - Added missing `accessibilityLabelledBy` TypeScript type

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Test Plan: Ran `yarn test-typescript` and `yarn test-typescript-offline` and there were no errors.

Reviewed By: christophpurrer

Differential Revision: D42604287

Pulled By: NickGerleman

fbshipit-source-id: 476d24d1c0257be787b7e84c2c11bcadc3527979
2023-01-19 05:57:51 -08:00
Dimitar Nestorov 71c4f57baf Add accessibilityLanguage type (#35882)
Summary:
`accessibilityLanguage` is missing from `AccessibilityPropsIOS` TypeScript interface

## Changelog

[GENERAL] [FIXED] - Added missing `accessibilityLanguage` TypeScript type

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Test Plan: Ran `yarn test-typescript` and `yarn test-typescript-offline` and there were no errors.

Reviewed By: christophpurrer

Differential Revision: D42604363

Pulled By: NickGerleman

fbshipit-source-id: fb8dd4b5bba78a080473a9dc7b49a07587530229
2023-01-19 05:52:57 -08:00
Sam Zhou f4072b1e00 Pre-suppress errors ahead of 0.197.0 release
Summary: Changelog: [internal]

Reviewed By: mroch

Differential Revision: D42558696

fbshipit-source-id: 3367fb1233c9630bd31b0ae9950f7b2f13438057
2023-01-17 22:24:49 -08:00
Rob Walker 8ea1cba06a Remove iOS flag from scrollEventThrottle prop (#35840)
Summary:
The `scrollEventThrottle` prop is documented as only applying to iOS, but in [this commit](https://github.com/facebook/react-native/commit/cf55fd587e6cc82a73079be6076d244ab72fa359) it was also implemented for Android, but the documentation was not updated.

## Changelog
[GENERAL] [CHANGED] - Removed iOS flag from `scrollEventThrottle` docs
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Test Plan: I've not been able to find how to build the docs locally, so I don't have a screenshot of the changes :(

Reviewed By: cipolleschi

Differential Revision: D42530943

Pulled By: sammy-SC

fbshipit-source-id: 2948eca2621712ccd832f4f99f1aab0cbd4af2d0
2023-01-17 05:38:19 -08:00
Ruslan Lesiutin 465e937533 internalize Slider module (#35825)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35825

Changelog:
[iOS][Removed] - removed Slider module
[Android][Removed] - removed Slider module

Reviewed By: cortinico

Differential Revision: D42394124

fbshipit-source-id: 92ba3bc50d16996a597148fa2f8178e6bd6d8eb7
2023-01-16 02:42:18 -08:00
Luna Wei ac54a5ba2b Remove SafeAreaView flow declaration
Summary: Changelog: [Internal] Remove flow declaration for SafeAreaView in preparation for TS generation

Reviewed By: christophpurrer

Differential Revision: D42349686

fbshipit-source-id: b792313b18f3804d8c68955afd918ec8cbb0b80f
2023-01-11 14:29:37 -08:00
Luna Wei da415398bd Remove AccessibilityInfo.flow
Summary: Changelog: [Internal] Remove flow declaration in preparation for TS generation

Reviewed By: christophpurrer

Differential Revision: D42350837

fbshipit-source-id: 05e80226931cdea04e7f14ddf2876297ab31ada7
2023-01-11 14:29:37 -08:00
Ruslan Lesiutin 0ff7b7fac2 refactor(react-native-github): move DatePickerIOS to internal (#35366)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35366

# Changelog:
[JS][Removed] - removed DatePickerIOS module
[iOS][Removed] - removed DatePickerIOS module

Reviewed By: lunaleaps

Differential Revision: D41163591

fbshipit-source-id: fda31d6f3a5d7a9ca3e50ae3b4817e7deb22819c
2023-01-09 08:53:29 -08:00
Ruslan Lesiutin ac66512eb3 Revert D41069547: Multisect successfully blamed D40984397 for test or build failures (#35789)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35789

Changelog: [Internal]

This diff is reverting D41069547 (https://github.com/facebook/react-native/commit/fee9510b2d8ff73be632dbe6f07003f001104836) D41062668 (https://github.com/facebook/react-native/commit/4c40014d43abe88b17db75aca9de9cca349ecbcc) D40984397 (https://github.com/facebook/react-native/commit/05968d16e1c4714a7ebfb08fff60ec7d5c914de1)
D40984397 (https://github.com/facebook/react-native/commit/05968d16e1c4714a7ebfb08fff60ec7d5c914de1) has been identified to be causing the following test or build failures:

We're generating a revert to back out the changes in this diff, please note the backout may land if someone accepts it.

allow-large-files

Differential Revision: D42371475

fbshipit-source-id: daa01c9215811c397f5cef958fd4620f36295b60
2023-01-06 13:06:17 -08:00
Gabriel Donadel Dall'Agnol 4ae4984094 feat: Add logical border radius implementation (#35572)
Summary:
This PR implements logical border-radius as requested on https://github.com/facebook/react-native/issues/34425. This implementation includes the addition of the following style properties

- `borderEndEndRadius`, equivalent to `borderBottomEndRadius`.
- `borderEndStartRadius`, equivalent to `borderBottomStartRadius`.
- `borderStartEndRadius`, equivalent to `borderTopEndRadius`.
- `borderStartStartRadius`, equivalent to `borderTopStartRadius`.

## Changelog

[GENERAL] [ADDED] - Add logical border-radius implementation

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

Test Plan:
1. Open the RNTester app and navigate to the `RTLExample` page
2. Test the new style properties through the `Logical Border Radii Start/End` section

https://user-images.githubusercontent.com/11707729/206623732-6d542347-93f9-40da-be97-f7dcd5f66ca9.mov

Reviewed By: necolas

Differential Revision: D42002043

Pulled By: NickGerleman

fbshipit-source-id: a0aa9783c280398b437aeb7a00c6eb3f767657a5
2023-01-06 06:00:03 -08:00
Ruslan Lesiutin 05968d16e1 refactor(react-native-github): internalized Slider JS files
Summary:
# Changelog:
[JS][Removed] - Removed Slider module js files

Reviewed By: NickGerleman

Differential Revision: D40984397

fbshipit-source-id: 8ff451d0f4d821af96c45277956042fa181dd4c5
2023-01-05 06:12:47 -08:00
Luna Wei 9c57a7f209 ESM ActivityIndicator
Summary: Changelog: [General][Changed] ActivityIndicator and remove .flow

Reviewed By: yungsters

Differential Revision: D42203449

fbshipit-source-id: 52ab1111166d23b7304e8406f299d23f9fd6f399
2023-01-03 18:09:06 -08:00
Luna Wei aa8e69b696 ESM processColor
Summary: Changelog: [General][Changed] - ESM processColor

Reviewed By: yungsters

Differential Revision: D42200330

fbshipit-source-id: aac5650ce0b45400400ebee4e8e8b36148539955
2023-01-03 18:09:06 -08:00
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
Gabriel Donadel Dall'Agnol 9669c10afc feat: Add Fabric implementation of inset logical properties (#35692)
Summary:
This PR implements `inset` logical properties as requested on https://github.com/facebook/react-native/issues/34425. This implementation includes the addition of the following style properties

- `inset`, equivalent to `top`, `bottom`, `right` and `left`.
- `insetBlock`, equivalent to `top` and `bottom`.
- `insetBlockEnd`, equivalent to `bottom`.
- `insetBlockStart`, equivalent to `top`.
- `insetInline`, equivalent to `right` and `left`.
- `insetInlineEnd`, equivalent to `right` or `left`.
- `insetInlineStart`, equivalent to `right` or `left`.

## Changelog

[GENERAL] [ADDED] - Add Fabric implementation of inset logical properties

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

Test Plan:
1. Open the RNTester app and navigate to the `View` page
2. Test the new style properties through the `Insets` section

<table>
<tr>
    <td>Android</td>
    <td>iOS</td>
</tr>
  <tr>
    <td><img src="https://user-images.githubusercontent.com/11707729/208821212-fbbac6ed-09a4-43f4-ba98-dfd2cbabf044.png"  alt="1" width="360px"   />
    </td>
<td>
<img src="https://user-images.githubusercontent.com/11707729/208816997-ef044140-8824-4b1b-a77b-085f18ea9e0e.png" alt="2" width="360px"  />
</td>
   </tr>
</table>

Reviewed By: NickGerleman

Differential Revision: D42193661

Pulled By: ryancat

fbshipit-source-id: 3db8bcd2c4db0ef4886b9ec49a46424d57362620
2022-12-21 20:07:35 -08:00
Nick Gerleman 76a14454d7 Add missing AccessibilityInfo Types to TS Typings
Summary:
This adds some missing public methods on AccessibilityInfo.

Changelog:
[General][Fixed] - Add missing AccessibilityInfo Types to TS Typings

Reviewed By: christophpurrer

Differential Revision: D42113713

fbshipit-source-id: bf1945f310b716ff8584dd47fc27752dc592e473
2022-12-17 11:58:19 -08:00
Nick Gerleman 0d091318ed Fix types for deprecated scrollTo fields
Summary:
This was renamed in Flow but not in TS.

Changelog:
[General][Fixed] - Fix types for deprecated scrollTo fields

Reviewed By: christophpurrer

Differential Revision: D42040913

fbshipit-source-id: 5d9746be7b785bea8613f199d39940c4d5d7d138
2022-12-14 15:38:03 -08:00
Nick Gerleman e1af6302fc Mark scrollToEnd animated as optional
Summary:
The flow type and inheriting TS types mark animated as optional, mark it here as well.

Changelog:
[General][Fixed] - Mark scrollToEnd animated as optional

Reviewed By: christophpurrer

Differential Revision: D42036647

fbshipit-source-id: 59d408adc639ee1e0ca040301511c64d7ba55bfe
2022-12-14 15:04:55 -08:00
Ruslan Lesiutin 74859c7f0d refactor(react-native/DatePickerAndroid): internalize native module
Summary: Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D41772143

fbshipit-source-id: 842934c930d1f5209f65a70fff9919a99c330bda
2022-12-07 17:06:07 -08:00
Samuel Susla 6fa51e0c47 Fix flow types in NativeUIManager
Summary:
changelog: [internal]

Fix Flow types for UIManager measure functions.
Host platform does not accept null value for reactTag parameter. It errors if null is passed. This moves error closer to developers as Flow can catch it.

Reviewed By: javache

Differential Revision: D41614452

fbshipit-source-id: 2216c195808b8a1aae58c7cb2fa15be8a073e222
2022-12-07 08:37:35 -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
Rujin Cao 285a98084e @emails -> @oncall (miscs)
Differential Revision: D41063745

fbshipit-source-id: 395ccd254c7410b96915156d59a584d3b255faa8
2022-11-22 01:36:05 -08:00
Gabriel Donadel Dall'Agnol 8b1f6e09c1 Fix TouchableOpacity componentDidUpdate causing an excessive number of pending callbacks (#35387)
Summary:
The commit https://github.com/facebook/react-native/commit/3eddc9abb70eb54209c68aab7dbd69e363cc7b29 included on v0.69 introduced a wrong `if` statement inside the `componentDidUpdate` function of the `TouchableOpacity` component. As this `if` statement always evaluates to `true` (`(true || false) !== undefined`) we end up making unnecessary calls to the `_opacityInactive` method every time the component props changes, e.g. every time a `<Text>` inside the TouchableOpacity changes we call this function over and over, and this has been causing some performance issues on big lists.

This PR fixes this problem by adjusting the `componentDidUpdate` function to only call  `_opacityInactive` when necessary.

Closes https://github.com/facebook/react-native/issues/34442
Closes https://github.com/facebook/react-native/issues/32476

## Changelog

[General] [Fixed] - Fix TouchableOpacity componentDidUpdate causing an excessive number of pending callbacks

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

Test Plan:
1. Open the RNTester app and navigate to the `Touchable* and onPress` page
2. Test the `TouchableOpacity` component through the many sections

Reviewed By: cipolleschi

Differential Revision: D41397396

Pulled By: ryancat

fbshipit-source-id: 24863b5cbbdd2f3dd1f654b43d7031560937b888
2022-11-18 12:46:10 -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
Nick Gerleman 67b8e182fa Add Fabric implementation of flow-relative padding and margin (#35342)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35342

This is a native implementation of the JS shimmed layout-specific properties in https://github.com/facebook/react-native/pull/35316.

There is an experiment splitting the prop splitting codepath in Fabric, so this change effectively has two implementations depending on whether `enablePropIteratorSetter` is enabled.

None of these changes make sense to propagate Yoga. `inlineEnd`, etc are already mapped to `YGEdgeStart` and `YGEdgeEnd`, but RN's mapping used a different name. Then `blockStart`, `blockEnd`, map directly to existing edges in all cases since we don't support a writing mode.

On web, the last value in the style which computes the given dimension is given precedence. E.g. if "left" comes after "start" it will be chosen. Yoga stylesheets are unordered, and precedence for edges is given based on specificity (left > start > horizontal > all).

We give precedence to new renamings (e.g. start to inlineStart), but to preserve consistent behavior, we give precedence to specific edges before overwriting them with flow relative ones (e.g. marginTop has precedence over marginBlockStar).

Changelog:
[General][Added] - Add Fabric implementation of flow-relative padding and margin

Reviewed By: javache

Differential Revision: D41267765

fbshipit-source-id: 896e2ed71fe8bf83aef00b0a9d70fd20b2ce47a7
2022-11-16 12:31:33 -08:00
Gabriel Donadel Dall'Agnol 72d3da19ce chore: Update Text props aria-labelledby documentation (#35327)
Summary:
`aria-labelledby` Flow types were added to the Text props on https://github.com/facebook/react-native/commit/f353119113d6fc85491765ba1e90ac83cb00fd61  but the text component does not support `accessibilityLabelledBy`, which is the prop we were supposed to map `aria-labelledby` to. As the Text component does not really support `aria-labelledby` this PR updates the `TextProps` documentation to explain that this prop is necessary for cross-platform purposes and that other platforms need it.

## Changelog

[Android] [Changed] - Add notes to `aria-labelledby` from Text props

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

Test Plan: Ensure CI is green

Reviewed By: necolas

Differential Revision: D41280877

Pulled By: lunaleaps

fbshipit-source-id: 81cf016bcf3117f15385ddd119c44d6f9fdd6b68
2022-11-14 17:16:20 -08:00
Tim Yung 7cf4cf3afb ScrollView: Fix ref (and innerViewRef) Transition
Summary:
Normally when a `ref` prop supplied to a component is changed, the old `ref` receives `null` and the new `ref` receives the active component instance.

However, the current implementation of `ScrollView` has a bug where this does not happen (i.e. changing `ref` or `innerViewRef` does not cause either the old or new refs to be updated). This bug is due to a subtle issue with how `ScrollView` internally memoizes the `ref` (or `innerViewRef`) that is passed into the native component.

This commit fixes this behavior so that `ScrollView`'s `ref` and `innerViewRef` have the correct behavior.

Changelog:
[General][Fixed] When a ScrollView's `ref` or `innnerViewRef` changes, the old ref will now be invoked with `null` and the new ref with the active instance. (Previously, changing `ref` or `innerViewRef` on a `ScrollView` would be treated as though the ref had not changed at all.)

Reviewed By: sammy-SC

Differential Revision: D41208895

fbshipit-source-id: b465f666076edbef410cdf9661e040e1d8fa0404
2022-11-14 08:50:22 -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
Tim Yung 99381de753 ScrollView: Cleanup Jest Tests
Summary:
Cleans up `ScrollView-test.js` to be easier to read and to include a unit test for `ref`.

This prepares the Jest test suite to be extended with an additional test to validate a bug with `ref` invalidation.

Changelog:
[Internal]

Reviewed By: sammy-SC

Differential Revision: D41208894

fbshipit-source-id: 6d79adf131602292f7aa3180b1c230643e9baf16
2022-11-12 08:35:29 -08:00
Mike Vitousek 8c2a4d0d26 Annotate React hooks in xplat, defaulting to any
Summary:
Add explicit annotations to React hook callbacks as required for Flow's Local Type Inference project. This codemod prepares the codebase to match Flow's new typechecking algorithm. The new algorithm will make Flow more reliable and predictable.

This diff adds `any` or `$FlowFixMe` in cases where more precise types could not be determined.

Details:
- Codemod script: `.facebook/flowd codemod annotate-react-hooks ../../xplat/js --default-any --write`
- Local Type Inference announcement: [post](https://fb.workplace.com/groups/flowlang/posts/788206301785035)
- Support group: [Flow Support](https://fb.workplace.com/groups/flow)

drop-conflicts
bypass-lint

Reviewed By: SamChou19815

Differential Revision: D41231214

fbshipit-source-id: d5f5ce8d61020baa1138292c9e9f1c69dffd324c
2022-11-11 17:04:38 -08:00
Mike Vitousek ed02d4baf0 Annotate implicit instantiations in xplat, defaulting to any
Summary:
Add explicit annotations to underconstrained implicit instantiations as required for Flow's Local Type Inference project. This codemod prepares the codebase to match Flow's new typechecking algorithm. The new algorithm will make Flow more reliable and predictable.

This diff adds `any` or `$FlowFixMe` in cases where more precise types could not be determined.

Details:
- Codemod script: `.facebook/flowd codemod annotate-implicit-instantiations ../../xplat/js --default-any --write`
- Local Type Inference announcement: [post](https://fb.workplace.com/groups/flowlang/posts/788206301785035)
- Support group: [Flow Support](https://fb.workplace.com/groups/flow)

drop-conflicts
bypass-lint

Reviewed By: SamChou19815

Differential Revision: D41226960

fbshipit-source-id: e5e3edbb1aed849f90cc683a4d416a9a2f8f3a19
2022-11-11 12:54:51 -08:00
Pieter De Baets 8a59153bd7 Remove $TEMPORARY$object types
Summary:
This was left over from an old codemod.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D41154548

fbshipit-source-id: 0b5fb3e78491b66ebaf13555f80e0265a25dc7d8
2022-11-10 04:48:13 -08:00
Ruslan Lesiutin 1453ef1a88 refactor(react-native-github): move ProgressViewIOS to internal (#35277)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35277

# Changelog:
[JS][Removed] - removed ProgressViewIOS module
[iOS][Removed] - removed native iOS sources of ProgressViewIOS

Reviewed By: lunaleaps

Differential Revision: D40937475

fbshipit-source-id: 9060adf3c99727af4eeffc767ccfd0a70574859d
2022-11-09 16:09:31 -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
fabriziobertoglio1987 55c0df43b9 Adding pager, scrollview, viewgroup, webview, drawer roles (#34477)
Summary:
- adds missing roles
- adds custom roles that don't exist in TalkBack (see the [compositor.json][10] and [string.xml][11] files).
- fixes [issues with Drawer][12]
- fixes issues with ScrollView missing roles
- seek control already exist as adjustable https://github.com/facebook/react-native/pull/34477/commits/d460d097ac0f5df8002e072711023517905f9ca9

Relevant https://github.com/facebook/react-native/issues/30839#issuecomment-1222293556
fixes https://github.com/facebook/react-native/issues/30839

## Changelog

[Android] [Fixed]  - Adding pager, scrollview, viewgroup, webview, drawer roles

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

Test Plan:
Android
- Drawer Layout and ScrollView (02/09/22) https://github.com/facebook/react-native/pull/34477#issuecomment-1235293165
- sliding drawer, drawer layout, icon menu https://github.com/facebook/react-native/pull/34477#issuecomment-1224112650
- Horizontal and Vertical ScrollView https://github.com/facebook/react-native/pull/34477#issuecomment-1225478289
- Toast https://github.com/facebook/react-native/pull/34477#issuecomment-1225369629
- CheckedTextView https://github.com/facebook/react-native/pull/34477#discussion_r959329833
- Spinner (dropdownlist) https://github.com/facebook/react-native/pull/34477#discussion_r959374894
- EditText https://github.com/facebook/react-native/pull/34477#discussion_r959412185
- WebView https://github.com/facebook/react-native/pull/34477#discussion_r959417518
- Testing chime_up and chime_down sound feedback in Scrollable https://github.com/facebook/react-native/pull/34477#issuecomment-1238882030

iOS https://github.com/facebook/react-native/pull/34477#issuecomment-1232418595

[10]: https://github.com/google/talkback/blob/771de7cdbf55b6adb4ca4c64c27a52584f2337cc/compositor/src/main/res/raw/compositor.json#L1082-L1108
[11]: https://github.com/google/talkback/blob/771de7cdbf55b6adb4ca4c64c27a52584f2337cc/compositor/src/main/res/values/strings.xml#L223
[12]: https://github.com/facebook/react-native/pull/34477#issuecomment-1224112650

Reviewed By: NickGerleman

Differential Revision: D39894307

Pulled By: blavalla

fbshipit-source-id: 4a8da78bae485ead0523689631d88d1031a07b74
2022-11-07 23:25:33 -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
Gabriel Donadel Dall'Agnol e3e635ef84 feat: Add "option" to available role values (#35137)
Summary:
As pointed out by efoken on https://github.com/facebook/react-native/issues/34424#issuecomment-1283854395 we forgot we add the `option` value to the `role` prop, so this PR adds this missing value as requested on https://github.com/facebook/react-native/issues/34424.

## Changelog

[General] [Added] - Add "option" to available role values

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

Test Plan: Ensure that CI is green as there isn't much to test in this case because we're just adding a value that maps to `undefined`

Reviewed By: jacdebug

Differential Revision: D40849497

Pulled By: NickGerleman

fbshipit-source-id: 5e3e24c0ff05c361a7a8dc1ee1f20ba3fb6988ca
2022-10-31 04:47:35 -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
ankit-tailor 7a19af7fb6 fix: add mixed to aria-checked typings (#34633)
Summary:
`aria-checked` prop should accept `mixed` as value as given [here](https://www.w3.org/WAI/GL/wiki/Using_WAI-ARIA_aria-checked%3Dmixed) and also [accessibilityState.checked](https://reactnative.dev/docs/accessibility#accessibilitystate) accepts mixed to represent checkboxes. This change refers to issue https://github.com/facebook/react-native/issues/34424 and PR https://github.com/facebook/react-native/pull/34524

## Changelog

[General] [Added] - Added `mixed` value for `aria-checked`.

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

Test Plan:
```js
<TouchableOpacity
  accessibilityRole="checkbox"
  aria-checked="mixed"
  accessibilityHint="click me to change state">
  <Text>Checkbox example</Text>
</TouchableOpacity>
```

Reviewed By: lunaleaps

Differential Revision: D39382158

Pulled By: necolas

fbshipit-source-id: fa026274111305cc0bcbb42ed974ca1be7d779a5
2022-10-26 11:47:58 -07:00