Skip to content
Permalink
Browse files
RN: Delete TextInput.selectionState Prop
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 2becdfd4041f7f28138ba3a61c03e17c06dc2e50
Showing 3 changed files with 1 addition and 198 deletions.
@@ -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');
@@ -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.
@@ -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) {
@@ -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();
}
},
@@ -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) {
@@ -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) {
@@ -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');

@@ -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.

This file was deleted.

0 comments on commit 2becdfd

Please sign in to comment.