Skip to content

Commit dabb78b

Browse files
sherginfacebook-github-bot
authored andcommitted
Removing <TextInput autoGrow={true}>
Summary: `autoGrow` feature was/is totally awesome but... nowadays <TextInput> component is always autoexpandable (on both iOS and Android), so we don't need JavaScript implementation of this anymore. Sometimes it is even harmfull (see T23403231). I am sorry, sumkit. You are still awesome. :) Reviewed By: sahrens Differential Revision: D6553514 fbshipit-source-id: 1d24a2f2c046f514bd6b6318797a607b6e1841d0
1 parent 0673ac2 commit dabb78b

File tree

1 file changed

+4
-42
lines changed

1 file changed

+4
-42
lines changed

Libraries/Components/TextInput/TextInput.js

+4-42
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,6 @@ const TextInput = createReactClass({
219219
* The default value is `false`.
220220
*/
221221
autoFocus: PropTypes.bool,
222-
/**
223-
* If true, will increase the height of the textbox if need be. If false,
224-
* the textbox will become scrollable once the height is reached. The
225-
* default value is false.
226-
* @platform android
227-
*/
228-
autoGrow: PropTypes.bool,
229222
/**
230223
* Specifies whether fonts should scale to respect Text Size accessibility settings. The
231224
* default is `true`.
@@ -351,11 +344,6 @@ const TextInput = createReactClass({
351344
* instead of implementing the logic in JS to avoid flicker.
352345
*/
353346
maxLength: PropTypes.number,
354-
/**
355-
* If autogrow is `true`, limits the height that the TextInput box can grow
356-
* to. Once it reaches this height, the TextInput becomes scrollable.
357-
*/
358-
maxHeight: PropTypes.number,
359347
/**
360348
* Sets the number of lines for a `TextInput`. Use it with multiline set to
361349
* `true` to be able to fill the lines.
@@ -612,10 +600,6 @@ const TextInput = createReactClass({
612600
*/
613601
mixins: [NativeMethodsMixin, TimerMixin],
614602

615-
getInitialState: function() {
616-
return {layoutHeight: this._layoutHeight};
617-
},
618-
619603
/**
620604
* Returns `true` if the input is currently focused; `false` otherwise.
621605
*/
@@ -633,7 +617,6 @@ const TextInput = createReactClass({
633617
_focusSubscription: (undefined: ?Function),
634618
_lastNativeText: (undefined: ?string),
635619
_lastNativeSelection: (undefined: ?Selection),
636-
_layoutHeight: (-1: number),
637620

638621
componentDidMount: function() {
639622
this._lastNativeText = this.props.value;
@@ -766,6 +749,7 @@ const TextInput = createReactClass({
766749
onScroll={this._onScroll}
767750
/>;
768751
}
752+
769753
return (
770754
<TouchableWithoutFeedback
771755
onLayout={props.onLayout}
@@ -783,10 +767,7 @@ const TextInput = createReactClass({
783767

784768
_renderAndroid: function() {
785769
const props = Object.assign({}, this.props);
786-
props.style = this.props.style;
787-
if (this.state.layoutHeight >= 0) {
788-
props.style = [props.style, {height: this.state.layoutHeight}];
789-
}
770+
props.style = [this.props.style];
790771
props.autoCapitalize =
791772
UIManager.AndroidTextInput.Constants.AutoCapitalizationType[
792773
props.autoCapitalize || 'sentences'
@@ -804,9 +785,11 @@ const TextInput = createReactClass({
804785
if (childCount > 1) {
805786
children = <Text>{children}</Text>;
806787
}
788+
807789
if (props.selection && props.selection.end == null) {
808790
props.selection = {start: props.selection.start, end: props.selection.start};
809791
}
792+
810793
const textContainer =
811794
<AndroidTextInput
812795
ref={this._setNativeRef}
@@ -815,7 +798,6 @@ const TextInput = createReactClass({
815798
onFocus={this._onFocus}
816799
onBlur={this._onBlur}
817800
onChange={this._onChange}
818-
onContentSizeChange={this._onContentSizeChange}
819801
onSelectionChange={this._onSelectionChange}
820802
onTextInput={this._onTextInput}
821803
text={this._getText()}
@@ -878,26 +860,6 @@ const TextInput = createReactClass({
878860
this.forceUpdate();
879861
},
880862

881-
_onContentSizeChange: function(event: Event) {
882-
let contentHeight = event.nativeEvent.contentSize.height;
883-
if (this.props.autoGrow) {
884-
if (this.props.maxHeight) {
885-
contentHeight = Math.min(this.props.maxHeight, contentHeight);
886-
}
887-
this.setState({layoutHeight: Math.max(this._layoutHeight, contentHeight)});
888-
}
889-
890-
this.props.onContentSizeChange && this.props.onContentSizeChange(event);
891-
},
892-
893-
_onLayout: function(event: Event) {
894-
const height = event.nativeEvent.layout.height;
895-
if (height) {
896-
this._layoutHeight = event.nativeEvent.layout.height;
897-
}
898-
this.props.onLayout && this.props.onLayout(event);
899-
},
900-
901863
_onSelectionChange: function(event: Event) {
902864
this.props.onSelectionChange && this.props.onSelectionChange(event);
903865

0 commit comments

Comments
 (0)