Skip to content

Commit

Permalink
RN: Delete TextInput.selectionState Prop
Browse files Browse the repository at this point in the history
Summary:
Deletes the `selectionState` prop from `TextInput`.

It does not provide meaningful value over `onBlur`, `onFocus`, and `selectionState`.

Changelog:
[Breaking][TextInput] Removing `selectionState` prop, use `onBlur`, `onFocus`, and `onUpdate` instead.

Reviewed By: zackargyle, TheSavior

Differential Revision: D17879667

fbshipit-source-id: 03a4e239406932adad898d6d2a092e3bc2e6b064
  • Loading branch information
yungsters authored and facebook-github-bot committed Oct 12, 2019
1 parent 6376951 commit 2becdfd
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 198 deletions.
32 changes: 1 addition & 31 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
'use strict';

const DeprecatedTextInputPropTypes = require('../../DeprecatedPropTypes/DeprecatedTextInputPropTypes');
const DocumentSelectionState = require('../../vendor/document/selection/DocumentSelectionState');
const NativeMethodsMixin = require('../../Renderer/shims/NativeMethodsMixin');
const Platform = require('../../Utilities/Platform');
const React = require('react');
Expand Down Expand Up @@ -221,23 +220,6 @@ type IOSProps = $ReadOnly<{|
*/
enablesReturnKeyAutomatically?: ?boolean,

/**
* An instance of `DocumentSelectionState`, this is some state that is responsible for
* maintaining selection information for a document.
*
* Some functionality that can be performed with this instance is:
*
* - `blur()`
* - `focus()`
* - `update()`
*
* > You can reference `DocumentSelectionState` in
* > [`vendor/document/selection/DocumentSelectionState.js`](https://github.com/facebook/react-native/blob/master/Libraries/vendor/document/selection/DocumentSelectionState.js)
*
* @platform ios
*/
selectionState?: ?DocumentSelectionState,

/**
* When the clear button should appear on the right side of the text view.
* This property is supported only for single-line TextInput component.
Expand Down Expand Up @@ -1115,10 +1097,6 @@ const TextInput = createReactClass({
if (this.props.onFocus) {
this.props.onFocus(event);
}

if (this.props.selectionState) {
this.props.selectionState.focus();
}
},

_onPress: function(event: PressEvent) {
Expand Down Expand Up @@ -1161,7 +1139,7 @@ const TextInput = createReactClass({

this._lastNativeSelection = event.nativeEvent.selection;

if (this.props.selection || this.props.selectionState) {
if (this.props.selection) {
this.forceUpdate();
}
},
Expand Down Expand Up @@ -1198,10 +1176,6 @@ const TextInput = createReactClass({
) {
this._inputRef.setNativeProps(nativeProps);
}

if (this.props.selectionState && selection) {
this.props.selectionState.update(selection.start, selection.end);
}
},

_onBlur: function(event: BlurEvent) {
Expand All @@ -1211,10 +1185,6 @@ const TextInput = createReactClass({
if (this.props.onBlur) {
this.props.onBlur(event);
}

if (this.props.selectionState) {
this.props.selectionState.blur();
}
},

_onTextInput: function(event: TextInputEvent) {
Expand Down
17 changes: 0 additions & 17 deletions Libraries/DeprecatedPropTypes/DeprecatedTextInputPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

const DeprecatedColorPropType = require('./DeprecatedColorPropType');
const DeprecatedViewPropTypes = require('./DeprecatedViewPropTypes');
const DocumentSelectionState = require('../vendor/document/selection/DocumentSelectionState');
const PropTypes = require('prop-types');
const Text = require('../Text/Text');

Expand Down Expand Up @@ -388,22 +387,6 @@ module.exports = {
* The highlight and cursor color of the text input.
*/
selectionColor: DeprecatedColorPropType,
/**
* An instance of `DocumentSelectionState`, this is some state that is responsible for
* maintaining selection information for a document.
*
* Some functionality that can be performed with this instance is:
*
* - `blur()`
* - `focus()`
* - `update()`
*
* > You can reference `DocumentSelectionState` in
* > [`vendor/document/selection/DocumentSelectionState.js`](https://github.com/facebook/react-native/blob/master/Libraries/vendor/document/selection/DocumentSelectionState.js)
*
* @platform ios
*/
selectionState: (PropTypes.instanceOf(DocumentSelectionState): void),
/**
* The start and end of the text input's selection. Set start and end to
* the same value to position the cursor.
Expand Down
150 changes: 0 additions & 150 deletions Libraries/vendor/document/selection/DocumentSelectionState.js

This file was deleted.

0 comments on commit 2becdfd

Please sign in to comment.