Summary:
The flow team is rolling out exact-by-default object types to xplat/js. In order to do that, we need to take all inexact objects `{}` and turn them into explicitly inexact objects `{...}`.
This codemod does not change any type checking behavior. Prettier was run on all of the modified files with `format`.
drop-conflicts
Changelog: [Internal]
Reviewed By: zackargyle
Differential Revision: D18785076
fbshipit-source-id: c89c7fcc9eabe69859c8a488e03185fba5d06f80
Summary:
The former implementations of `TouchableHighlight` used `defaultProps` for `underlayColor`. However, the newly landed implementations use `??` which falls back to the default behavior if the prop is `null`.
This restores the former behavior so that, for example, supplying `underlayColor={null}` to `TouchableHighlight` will not fallback to black. (It probably should always have, but the intention of my rewrite was not to introduce a breaking change.)
Changelog:
[General] [Fixed] - Restore behavior for `underlayColor={null}` in `TouchableHighlight`.
Reviewed By: zackargyle
Differential Revision: D18806494
fbshipit-source-id: 4d33810e2f754f980385d76d81dc0f34006f4337
Summary:
Originally, normalizeColor.js was in Library/Color/ however, I noticed that its tests were in a completely different directly (Library/StyleSheet/__tests__) which was confusing. The other files such as processColor.js, setNormalizedAlphaColor.js had their tests in Library/StyleSheet/__tests__ as well.
## Changelog
[Internal] [Changed] - Moved normalizeColor.js to a more appropriate directory where its tests live.
Pull Request resolved: https://github.com/facebook/react-native/pull/27372
Test Plan: I simply moved a file and changed dependencies. The code should still function as is.
Reviewed By: rickhanlonii, mdvacca
Differential Revision: D18760210
Pulled By: yungsters
fbshipit-source-id: 4c2400acabab35ccbb2533faa5c1d6487c9bf48e
Summary:
Changelog:
[iOS] [Fixed] - Slider is now disabled properly on iOS if the disabled prop is set.
Reviewed By: yungsters
Differential Revision: D18758835
fbshipit-source-id: 4850ebf05380f241d49d40107de61fd840049779
Summary:
In AndroidTextInput, support codegen'd ViewCommands in native and add three commands that will eventually replace usage of setNativeProps on Android.
TextInput will use these commands in a future diff.
Changelog: [Internal]
Reviewed By: TheSavior
Differential Revision: D18612150
fbshipit-source-id: 5d427040686e8c5ab504dd845bc8ef863f558c35
Summary:
Changes `TouchableWithoutFeedback` so that `Props` is no longer exported as a Flow type.
Instead, other modules should use `React.ElementConfig<typeof TouchableWithoutFeedback>`.
Changelog:
[General] [Removed] - TouchableWithoutFeedback no longer exports Props. Use React.ElementConfig, instead.
Reviewed By: zackargyle, TheSavior
Differential Revision: D18718131
fbshipit-source-id: 0bd63123c49564fdab160d5fc8e7f1bf86da1fbe
Summary:
The experimentation code for `Touchable` is no longer necessary. Clean up all the injection points.
Changelog:
[Internal]
Reviewed By: TheSavior
Differential Revision: D18715851
fbshipit-source-id: 15fe59e218d89f222ae2183a1452718e460048cb
Summary:
Launches a new implementation of `TouchableBounce`.
It is implemented using `Pressability` and extends `React.Component`. Notably, `propTypes` no longer exist.
Changelog:
[Internal]
Reviewed By: TheSavior
Differential Revision: D18715856
fbshipit-source-id: df2300600a8f0f07fc669c1e28183a0ef3a6f695
Summary:
Launches a new implementation of `TouchableHighlight`.
It is implemented using `Pressability` and extends `React.Component`. Notably, `propTypes` no longer exist.
Changelog:
[General] [Changed] - TouchableHighlight overhauled as a class without propTypes.
Reviewed By: TheSavior
Differential Revision: D18715854
fbshipit-source-id: d4ea6ebd2ca9aef2af93ffad2fe75a96424514e5
Summary:
Launches a new implementation of `TouchableNativeFeedback`.
It is implemented using `Pressability` and extends `React.Component`. Notably, `propTypes` no longer exist.
Furthermore, `TouchableNativeFeedback` now behaves similar to `TouchableWithoutFeedback` on iOS (instead of rendering an error message).
Changelog:
[General] [Changed] - TouchableNativeFeedback overhauled as a class without propTypes. Also, replaced iOS error renderer.
Reviewed By: TheSavior
Differential Revision: D18715857
fbshipit-source-id: aa42c7547ac94340fde0ef30641cab7eb48ea81b
Summary:
Launches a new implementation of `TouchableOpacity`.
It is implemented using `Pressability` and extends `React.Component`. Notably, `propTypes` no longer exist.
Changelog:
[General] [Changed] - TouchableOpacity overhauled as a class without propTypes.
Reviewed By: TheSavior
Differential Revision: D18715858
fbshipit-source-id: 06ba5fc7eaacdbb7dc12d1564cc5d04e1a991229
Summary:
Launches a new implementation of `TouchableWithoutFeedback`.
It is implemented using `Pressability` and extends `React.Component`. Notably, `propTypes` no longer exist.
Changelog:
[General] [Changed] - TouchableWithoutFeedback overhauled as a class without propTypes.
Reviewed By: TheSavior
Differential Revision: D18715852
fbshipit-source-id: f2eb28e3b8500bfcd8db44fc6bdbc0476193723a
Summary:
The following accessibility properties was added for view but not for Touchables - importantForAccessibility, accessibilityLiveRegion, accessibilityViewIsModal and accessibilityElementsHidden. This PR is to extend the support for all touchables.
## Changelog
[General] [Added] - Add missing accessibility props on Touchables
Pull Request resolved: https://github.com/facebook/react-native/pull/27293
Test Plan: Tested in RNTester app.
Differential Revision: D18650884
Pulled By: yungsters
fbshipit-source-id: 2172ac55a8c8803d7d923511f43b2598593ea1d2
Summary:
When using `react-native-screen` which uses native view controller animations for navigation `TextInput` with `autoFocus` causes a weird animation glitch.
Removing the requestAnimationFrame will cause the focus command to be sent in the same batch as starting screen transitions which fixes the issue.
It is unclear why the rAF was added in the first place as it was part of the initial RN open source commit. If someone at facebook has more context that would be great to make sure it doesn't cause unintended side effects.
Credits to kmagiera for figuring out this
## Changelog
[General] [Fixed] - Remove requestAnimationFrame when focusing input on mount
Pull Request resolved: https://github.com/facebook/react-native/pull/27217
Test Plan:
- Tested in an app using react-native-screen to make sure the animation glitch is fixed
- Tested in RNTester to make sure it doesn't cause other issues when not using react-native-screens
Before:
![1](https://user-images.githubusercontent.com/2677334/68799447-2ce5c100-0626-11ea-8310-a9ac9e9419b6.gif)
After:
![2](https://user-images.githubusercontent.com/2677334/68799450-2fe0b180-0626-11ea-865f-ef88f7307831.gif)
Differential Revision: D18666991
Pulled By: TheSavior
fbshipit-source-id: 66664c89e06c9ae65074ddcc4688dc5109fc9c72
Summary:
Modernizing this code a bit more, converting it to hooks.
Changelog:
[General][Changed] Converted TextInput to use React hooks
[General][Fixed] TextInput now properly sends native the end selection location on change
(Note: this ignores all push blocking failures!)
Reviewed By: JoshuaGross
Differential Revision: D18581712
fbshipit-source-id: 62d6ea8489fa019ddf941c520930365f2c4887d8
Summary:
We are rolling out exact-by-default syntax to xplat/js.
I had to manually move around some comments to preserve proper placement.
Changelog: [Internal]
Reviewed By: jbrown215
Differential Revision: D18633611
fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
Summary:
Changelog: [Internal]
Fixing a red screen on the RN picker.
Looks like the picker gets confused when for unknown reasons a native value is undefined. In that case we stick to the JS value as it is specified in the comment.
https://fb.workplace.com/groups/rn.support/permalink/2997783536936908/
NOTE : Native fix was landed, this add an extra layer on the JS side
Reviewed By: mmmulani
Differential Revision: D18443005
fbshipit-source-id: 9511ac90f2d9e6186c6c0de3b673cc535cdb9fa6
Summary:
This variable is never set and only ever removed
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D18537317
fbshipit-source-id: bbb084e2ea5408fc59ef3853b2ec74bf22afbe21
Summary:
These tests need to be consistent with every test so a helper makes more sense.
Changelog: [Internal]
Reviewed By: rickhanlonii
Differential Revision: D18500439
fbshipit-source-id: de535156d370102bad88e556ad3d2a0d5443e4e2
Summary:
Changelog: [Internal]
Introduce native command `setNativeRefreshing`, it has the word Native in order to avoid name conflict with setRefreshing in Android implementation. Even this component is iOS only, it would make it easier to merge them in the future.
Introduce `RCTRefreshableProtocol` and make `RCTRefreshControl` and `RCTPullToRefreshViewComponentView` to conform to the protocol so view manager can forward command to both, Paper and Fabric component.
Reviewed By: mmmulani
Differential Revision: D18475804
fbshipit-source-id: 4c19225784efc931b7b8f2d2671cc839bce429bf
Summary:
This is the first diff in the series. It removes Flow types for this feature to verify that we actually do not have any usages. After it lands, we will remove actual support on the native side.
There are several reasons why removing it is a good idea:
* There is no any evidence that this feature is actually useful. That was discussed several times (e.g. see T7936714) during RN lifetime and the overall consensus is: We need something else, something like sync `onChange` event instead of it.
* Supporting the previous point, it's not used (at least inside Facebook). I searched hard and I could find only one place where it's used: in the TextInput Example.
* To deliver more functionality we should lean towards W3C specs, this one is not W3C compliant.
* Supporting this Feature in Fabric is quite challenging, so I want to do it sooner than later.
* This feature was never documented.
Changelog: [Breaking] `<TextInput>::onTextInput` event was removed
Reviewed By: TheSavior
Differential Revision: D18456175
fbshipit-source-id: c7a8ed7a86b33ecc01d45497645fe249556fdf96
Summary:
TextInput now acts as a host component and can be passed directly to our new APIs that require a host component. Callsites no longer need to call
```
inputRef.getNativeRef()
```
We mutate the ref to the host component adding the imperative methods of the TextInput so you can still call `inputRef.clear` and `inputRef.isFocused`.
Changelog:
[General][Changed] TextInput now uses `forwardRef` allowing it to be used directly by new APIs requiring a host component.
Reviewed By: yungsters
Differential Revision: D18458408
fbshipit-source-id: 1f149fd575210d702fa0fdf3d05bb2162436a773
Summary:
When the TextInput class is exported directly Flow complains about some definitions because they don't properly define the export type. This change adds those types but still doesn't export the TextInput directly as there are more things that still need to get fixed.
Changelog:
[Internal]
Reviewed By: JoshuaGross
Differential Revision: D18444096
fbshipit-source-id: 18c88bbf1de5504f350681a71ea21d7e41876e49
Summary:
In order to make this more flow typed and modern we need to get it off of createReactClass. This change converts the class as is with no intended behavior changes to an ES6 class.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18443018
fbshipit-source-id: 831921976e9de8e965180cdefd1c4a154f04bfea
Summary:
We need to get rid of NativeMethodsMixin. Normally we'd use forwardRef to the HostComponent, however we can't do this here because TextInput has its own imperative methods. I want to refactor this into a class and after that will revisit how to get rid of these methods.
Changelog:
[Internal]
Reviewed By: JoshuaGross
Differential Revision: D18436162
fbshipit-source-id: 0c81fa8b31b3248cbab8680ff680dd09c61c76e2
Summary:
Reordering the methds in TextInput to be a bit more consistent.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435732
fbshipit-source-id: 05a1d9d2c70a4b5fa00a3dc6be0520a216a24106
Summary:
We don't need a local mutable copy of props.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435731
fbshipit-source-id: 13ec1a78ca26b1372a4aed484a821204a93b6437
Summary:
The TouchableWithoutFeedback is almost exactly the same between both branches.
The responderReject prop was added in https://github.com/facebook/react-native/pull/16755.
The PR seems to say that it is the default behavior on Android. I don't want to make risky changes in this refactor so I'm not doing anything special about that prop for now.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435733
fbshipit-source-id: 372d17d8e67884930409a6a863757944cec4737e
Summary:
These functions are quite similar and I'm going to refactor out the shared pieces. To make it easy to review this change just inlines those two functions with no other changes.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435734
fbshipit-source-id: 826f510359358427856993b536d41054ddf8c792
Summary:
As a part of the migration from `setNativeProps` in Fabric and Paper, we are replacing it by view commands in the RefreshControl component on Android.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D18475428
fbshipit-source-id: f2e978d88e34c74771f8582247ecc82b2b942557
Summary:
As a part of the migration from `setNativeProps` in Fabric and Paper, we are replacing it by view commands in the Checkbox component on Android.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D18451524
fbshipit-source-id: 566f3574b85a1ae97f78b2fb95548b8529c0c92f
Summary:
Fabric doesn't support setNativeProps, so we have to use commands instead to set the value of the native component.
Changelog: [Android] [Added] - Add setNativeSelectedPosition command to ReactPickerManager
Reviewed By: mdvacca
Differential Revision: D18007791
fbshipit-source-id: dfa26792205189a336ab43b1c51f43f8f57c8e72
Summary:
ScrollView isn't using codegen, therefore we need to manually write commands interface. I also typed commands so it uses `Double` instead of `number`.
Changelog: [Internal]
Reviewed By: TheSavior
Differential Revision: D18371887
fbshipit-source-id: 3bd11b9969b80ce6d2302e2f0da28884e9221b7e
Summary:
We are going to be switching event target and current target from being a reactTag to being a host instance.
This doesn't actually change what the actual type of this key is, but is split out like this to make diffs smaller and easier to review. Actual behavior changes will be coming and tested in a future diff.
These are the only callsites I found that use target outside of the React renderers.
The other approach this change could take would be to make all the downstream callsites take both a tag or a HostComponent. That felt too difficult to do at the same time so I'm instead introducing these `findNodeHandle` calls temporarily.
The main thing we need to do is be able to change the callsites in the renderer to start sending the instance. Once everything is passing the instance instead of the tag then we can clean all these up cleanly.
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D18384435
fbshipit-source-id: b3a7e6a2778cb7dd9cdfe451cf869cd99641b167
Summary:
We are going to be switching event target and current target from being a reactTag to being a host instance.
This doesn't actually change what the actual type of this key is, but is split out like this to make diffs smaller and easier to review. Actual behavior changes will be coming and tested in a future diff.
These are the only callsites I found that use `currentTarget` outside of the React renderers.
Changelog:
[Internal]
Reviewed By: zackargyle, yungsters
Differential Revision: D18382470
fbshipit-source-id: 23add5498b38dc109b154479826f701c8a1920b9
Summary:
Changelog: [Internal]
Reverting the import to the previous local module style since importing from react-native seems to introduce some perf regression. We'll revisit this later in the future.
Reviewed By: yungsters
Differential Revision: D18383893
fbshipit-source-id: f11d46a4545768f39199fd6fd22fcf14905d0a74
Summary:
Add handwritten view config for AndroidHorizontalScrollContentView. Same as RCTScrollContentView, this native component has no props of its own other than what View accepts. It's simply used as a container for the horizontal ScrollView on Android.
Changelog: [Internal]
Reviewed By: rickhanlonii
Differential Revision: D18284673
fbshipit-source-id: 8cd6282a3b2e5c9876da5cc0e068b12dd56acfd8
Summary:
Adding a handwritten view config for AndroidHorizontalScrollView, the native component that's used with `<ScrollView horizontal={true} />` on Android. Native props are the same as `RCTScrollView`, so I'm reusing the type for that.
Changelog: [Internal]
Reviewed By: rickhanlonii
Differential Revision: D18284517
fbshipit-source-id: 7c81f72440b93d611f9574ad2c01a96530d07bf7
Summary:
Adding a handwritten view config for RCTScrollContentView. This host component doesn't actually have any props of its own separate from View; it's just a container for a ScrollView.
Changelog: [Internal]
Reviewed By: rickhanlonii
Differential Revision: D18283792
fbshipit-source-id: db95e981f54bef7c068b907c5d1fa52774dad147
Summary:
Adding a handwritten view config for RCTScrollView, to be used in DEV only (for now).
Changelog: [Internal]
Reviewed By: rickhanlonii
Differential Revision: D18263203
fbshipit-source-id: 975499f030c7caed9851bcde0be42c5058911ad5
Summary:
still some generated files in www that need to land before we can release 0.111 here.
drop-conflicts
Changelog: [Internal]
(Note: this ignores all push blocking failures!)
Reviewed By: dsainati1
Differential Revision: D18278838
fbshipit-source-id: b20c3fefb3aab7c5fb614b33d846c7548184f49a
Summary:
Changelog: DatePicker now uses commands instead of `setNativeProps`
We are moving away from `setNativeProps` in favour of commands API.
Reviewed By: shergin
Differential Revision: D17787870
fbshipit-source-id: aa532cbb7bfb3031c085e5122ab808522c437901
Summary:
Changelog: [Internal]
Moved the imports for `TurboModuleRegistry` and `TurboModule` from `react-native`. This was a jscodeshift with the script: P120688078
Reviewed By: yungsters
Differential Revision: D18262538
fbshipit-source-id: 48fac15229c897408928511c5ecbb42f17ec7b42
Summary:
I wrote up a bunch of context for this in response to #27038 by fat. That comment is reproduced here in this commit message. You can see it in it's original contxt here: https://github.com/facebook/react-native/pull/27038
Okay, here is what I think is happening. For context, here is a diagram I have of how focus and blur propagates through the system. This might be interesting to refer back to as you go through the rest of my explanation.
![graphviz (12)](https://user-images.githubusercontent.com/249164/67992345-982c9d80-fbf9-11e9-96ea-b091210dddbe.png)
ScrollView's scrollResponder is responsible for blurring text inputs when a touch occurs in the ScrollView but outside of the currently focused TextInput. The code for that is here:
6ba2769f0f/Libraries/Components/ScrollResponder.js (L301-L314)
This happens on `scrollResponderHandleResponderRelease` aka, touch up.
It checks for what the currently focused textinput is by calling `TextInputState.currentlyFocusedField()`.
That function is a JS variable that is being updated by calls to `TextInputState.focusTextInput` and `TextInputState.blurTextInput`:
6ba2769f0f/Libraries/Components/TextInput/TextInputState.js (L36-L71)
I added some console logs to those methods to see which ones are being called when running your repro (thanks for the repro!). **This is without your fix**
Click on and off:
```
// Click on input 1
focusTextInput input1
TextInput's _onFocus called
// Click on blank space
scrollResponderHandleResponderRelease blur input1
blurTextInput input1
TextInput's _onBlur called
```
Click on input1, then input 2, then off
```
// Click on input 1
focusTextInput input1
TextInput's _onFocus called for input1
// Click on input 2
focusTextInput input2
TextInput's _onBlur called for input1
TextInput's _onFocus called for input2
// Click on blank space
scrollResponderHandleResponderRelease blur input2
blurTextInput input2
TextInput's _onBlur called for input2
```
And now for the bug. Click on input 1, tab to 2, then off
```
// Click on input 1
focusTextInput input1
TextInput's _onFocus called for input1
// Tab to input 2
TextInput's _onBlur called for input1
TextInput's _onFocus called for input2
// Click on blank space
scrollResponderHandleResponderRelease blur input1
blurTextInput input1
```
Notice how `focusTextInput` was never called with input2 in the last example. Since this is the function that sets the `currentlyFocusedField` when we click on the blank space RN is trying to blur the first input instead of the second.
# The root cause
We are tracking the state of which field is focused in JS which has to stay in sync with what native knows is focused. We [listen to _onPress](6ba2769f0f/Libraries/Components/TextInput/TextInput.js (L1103-L1107)) and call `TextInputState.focusTextInput` in that handler. However, we don't currently have anything listening to other ways for an input to become focused (like tabbing) so it doesn't end up updating the `currentlyFocusedField`.
We have the same problem with blur that we actually fixed the same way you did here in this PR:
6ba2769f0f/Libraries/Components/TextInput/TextInput.js (L1182-L1189)
If you look back at my diagram at the beginning of this post, you'll notice the missing edge from `TextInput._onFocus` to `TextInputState.focusTextInput`. That's the problem. :)
The reason this solution works is because this function **is** the notification from native that an input was focused or blurred. This solution is *fine* because this updates the `currentlyFocusedID` but isn't great because it both sets that value and **calls the native code to focus or blur again**. Luckily the native code doesn't send an event back to JS if you try to blur an already blurred TextInput otherwise we'd have an infinite loop.
# The correct solution
The correct thing would probably be to have all of this tracking in native code and not in JavaScript code. That's a pretty big change though and very out of scope. Something for our team to keep in mind for the future.
A short term term solution would be to refactor `focusTextInput` and `blurTextInput` to pull out the part that sets the `currentlyFocusedID` that we could call from `TextInput` directly from `_onFocus` and `_onBlur`.
# ^This short term term solution is what this commit is doing.
Changelog:
[General][Changed] TextInput no longer does an extra round trip to native on focus/blur
Reviewed By: RSNara
Differential Revision: D18278359
fbshipit-source-id: 417566f25075a847b0f4bac2888f92fbac934096
Summary:
Instead of defining the default props as a property on the forwardRef, we can just inline it into the destructure.
Changelog:
[Internal]
Reviewed By: yungsters
Differential Revision: D18296180
fbshipit-source-id: c9e85a9869648983a01d84c36a5c581b357b427f