Граф коммитов

1561 Коммитов

Автор SHA1 Сообщение Дата
Jordan Brown 90ab8b89e8 Last pass over non-generated files for explicit inexact object rollout
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
2019-12-04 21:41:16 -08:00
Tim Yung 37d8440a8e Touchable: Restore `underlayColor={null}` Behavior
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
2019-12-04 09:35:46 -08:00
Isabel B d3980dceab moved normalizeColor and changed dependencies (#27372)
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
2019-12-03 16:05:22 -08:00
Andy Huang fa9ff07017 Pass disabled prop down to native implementation
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
2019-12-02 14:21:16 -08:00
Joshua Gross 7ab5eb4caf AndroidTextInput: support using commands instead of setNativeProps (native change)
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
2019-11-27 12:55:48 -08:00
Tim Yung 7bcae81299 RN: Stop Exporting TouchableWithoutFeedback Props
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
2019-11-27 07:48:40 -08:00
Tim Yung a516167526 RN: Delete Touchable Injection
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
2019-11-27 07:48:40 -08:00
Tim Yung 18d0cba3a9 RN: New `TouchableBounce`
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
2019-11-27 07:48:39 -08:00
Tim Yung 7c01172bef RN: New `TouchableHighlight`
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
2019-11-27 07:48:39 -08:00
Tim Yung 2185dd298a RN: New `TouchableNativeFeedback`
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
2019-11-27 07:48:39 -08:00
Tim Yung 88ae24f719 RN: New `TouchableOpacity`
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
2019-11-27 07:48:38 -08:00
Tim Yung ebf7d75816 RN: New `TouchableWithoutFeedback`
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
2019-11-27 07:48:38 -08:00
Sharon Gong 8c0c860e38 Add missing accessibility props to Touchables (#27293)
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
2019-11-23 10:28:07 -08:00
Janic Duplessis 5798cf2aa9 Remove requestAnimationFrame when focusing input on mount (#27217)
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
2019-11-22 16:13:57 -08:00
Eli White dff490d140 Convert TextInput to Hooks
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
2019-11-21 12:41:52 -08:00
George Zahariev 8553e1acc4 Exact-by-default codemod for react-native-github
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
2019-11-21 09:42:57 -08:00
Lucy Beatriz Gomez a7233e45a4 Fixing RN Picker
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
2019-11-20 20:16:13 -08:00
Eli White 7813e24cdb Remove unused _focusSubscription
Summary:
This variable is never set and only ever removed

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D18537317

fbshipit-source-id: bbb084e2ea5408fc59ef3853b2ec74bf22afbe21
2019-11-20 18:09:30 -08:00
Eli White e483bd4d49 Add Jest snapshot tests to TextInput
Summary:
$title

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D18536359

fbshipit-source-id: 382c81c094c0ae28ec3e203cb0726bdbccf755dc
2019-11-20 18:09:30 -08:00
Eli White 20a3bb52ce Convert component snapshot tests to a reusable helper
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
2019-11-20 18:09:30 -08:00
Samuel Susla 2d80a248cd Migrate RefreshControl to Native Commands
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
2019-11-19 10:06:56 -08:00
Valentin Shergin 3f7e0a2c96 Removing <TextInput>'s `onTextInput` event
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
2019-11-18 20:53:35 -08:00
Emily Janzer 719d52fb6b Remove unused import from ScrollViewViewConfig
Summary:
As titled

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18575837

fbshipit-source-id: 02e0b126bb783119f78e1eca82ee9fe9980529bc
2019-11-18 18:08:11 -08:00
Eli White bbc5c35a61 Convert to using forwardRef
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
2019-11-15 14:02:42 -08:00
Eli White 99dc4e204e Become compatible with Flow's TypesFirst
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
2019-11-15 14:02:42 -08:00
Eli White 8f601418ab Convert TextInput from NativeMethodsMixin to ES6 Class
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
2019-11-15 14:02:41 -08:00
Eli White ce314ba097 Inline NativeMethodsMixin
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
2019-11-15 14:02:41 -08:00
Eli White ca78497f73 Reorder methods
Summary:
Reordering the methds in TextInput to be a bit more consistent.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18435732

fbshipit-source-id: 05a1d9d2c70a4b5fa00a3dc6be0520a216a24106
2019-11-15 14:02:41 -08:00
Eli White c70a093dd2 Refactor props, sort
Summary:
Sorting these props to be consistent

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18435730

fbshipit-source-id: 259c6902bdaa3a7d4c7bdf8768d7f42191d5398b
2019-11-15 14:02:40 -08:00
Eli White b7bd85a2bf Refactor to not copy props
Summary:
We don't need a local mutable copy of props.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18435731

fbshipit-source-id: 13ec1a78ca26b1372a4aed484a821204a93b6437
2019-11-15 14:02:40 -08:00
Eli White 854fa96cae Factor out TouchableWithoutFeedback
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
2019-11-15 14:02:40 -08:00
Eli White eef7de6c6d TextInput merge _renderIOS and _renderAndroid methods
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
2019-11-15 14:02:39 -08:00
Daniel Sainati 0f8ad31745 @allow-large-files deploy Flow v0.112 to xplat
Summary: Changelog: [Internal]

Reviewed By: samwgoldman

Differential Revision: D18466454

fbshipit-source-id: 83c76ba06822a378cb0a8ea72cd0fb9d19f81a4b
2019-11-13 11:18:41 -08:00
Oleksandr Melnykov c5c3264a94 Add setNativeRefreshing command to SwipeRefreshLayoutManager
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
2019-11-13 10:21:04 -08:00
Oleksandr Melnykov cd1e34d4a2 Add setNativeValue command to ReactCheckBoxManager
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
2019-11-13 10:15:50 -08:00
Oleksandr Melnykov a62a685b14 Add setNativeSelectedPosition command to ReactPickerManager
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
2019-11-11 12:32:51 -08:00
Samuel Susla 8f607a7967 Fabric: add native commands support to ScrollView
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
2019-11-10 17:19:00 -08:00
Eli White 960a4767be Prepare event.target to be a HostComponent
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
2019-11-08 17:33:35 -08:00
Eli White 74f567ba3c Prepare `currentTarget` to accept number or host component
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
2019-11-08 17:33:35 -08:00
Kevin Gozali fb627dac6a TM JS: Revert to import from TurboModuleRegistry.js
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
2019-11-08 11:44:16 -08:00
Emily Janzer f3b3d777ab Add view config for AndroidHorizontalScrollContentView
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
2019-11-05 19:09:03 -08:00
Emily Janzer b7fac14b64 Add view config for AndroidHorizontalScrollView
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
2019-11-05 19:09:03 -08:00
Emily Janzer 1f2dc8997f Add (empty?) view config for RCTScrollContentView
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
2019-11-05 19:09:02 -08:00
Emily Janzer da39b07298 Add handwritten view config for RCTScrollView
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
2019-11-05 19:09:02 -08:00
Jordan Brown 93e58b2c96 Suppressions for 0.111
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
2019-11-05 17:36:23 -08:00
Samuel Susla 6fb5f81193 Use commands instead of setNativeProps in DatePicker
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
2019-11-05 10:41:41 -08:00
Kevin Gozali dd06f85bd0 TM JS: cleaned up TurboModuleRegistry types [2]
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
2019-11-04 18:51:05 -08:00
Eli White e9b4928311 TextInput: Don't do an extra round trip to native on focus/blur
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
2019-11-04 14:42:44 -08:00
Luna Wei 8e55e9ab1b TouchableNativeFeedback.android use codegenNativeCommands
Summary: Changelog: [Internal] Use `findHostInstance_DEPRECATED` for TouchableNativeFeedback

Reviewed By: TheSavior

Differential Revision: D18285029

fbshipit-source-id: 1c19c35e660519bee450e4fd37f18c03ec1883e0
2019-11-04 12:31:20 -08:00
Eli White 88f64a5782 Slider: Inline default props
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
2019-11-04 12:16:38 -08:00