[change] remove TextInput autogrow behaviour

This is non-standard. Removes 'maxNumberOfLines' too.

Ref #287
This commit is contained in:
Nicolas Gallagher
2017-04-13 20:46:28 -07:00
parent 32183bb92a
commit ab45211401
5 changed files with 6 additions and 36 deletions
+1 -7
View File
@@ -74,19 +74,13 @@ Determines which keyboard to open. (NOTE: Safari iOS requires an ancestral
Limits the maximum number of characters that can be entered.
(web) **maxNumberOfLines**: number = numberOfLines
Limits the maximum number of lines for a multiline `TextInput`.
(Requires `multiline` to be `true`.)
**multiline**: bool = false
If true, the text input can be multiple lines.
**numberOfLines**: number = 2
Sets the initial number of lines for a multiline `TextInput`.
Sets the number of lines for a multiline `TextInput`.
(Requires `multiline` to be `true`.)
-1
View File
@@ -34,7 +34,6 @@
"inline-style-prefixer": "^3.0.2",
"normalize-css-color": "^1.0.2",
"prop-types": "^15.5.8",
"react-textarea-autosize": "^4.0.4",
"react-timer-mixin": "^0.13.3"
},
"devDependencies": {
@@ -1,12 +1,11 @@
/* eslint-env jasmine, jest */
import React from 'react';
import TextareaAutosize from 'react-textarea-autosize';
import TextInput from '..';
import { mount, shallow } from 'enzyme';
const findNativeInput = wrapper => wrapper.find('input');
const findNativeTextarea = wrapper => wrapper.find(TextareaAutosize);
const findNativeTextarea = wrapper => wrapper.find('textarea');
const testIfDocumentIsFocused = (message, fn) => {
if (document.hasFocus && document.hasFocus()) {
@@ -89,21 +88,6 @@ describe('components/TextInput', () => {
expect(input.prop('maxLength')).toEqual(10);
});
test('prop "maxNumberOfLines"', () => {
const generateValue = () => {
let str = '';
while (str.length < 100) {
str += 'x';
}
return str;
};
const input = findNativeTextarea(
shallow(<TextInput maxNumberOfLines={3} multiline value={generateValue()} />)
);
expect(input.prop('maxRows')).toEqual(3);
});
test('prop "multiline"', () => {
// false
let input = findNativeInput(shallow(<TextInput />));
@@ -122,7 +106,7 @@ describe('components/TextInput', () => {
expect(input.length).toEqual(1);
input = findNativeTextarea(shallow(<TextInput multiline numberOfLines={3} />));
expect(input.prop('minRows')).toEqual(3);
expect(input.prop('rows')).toEqual(3);
});
test('prop "onBlur"', done => {
+3 -6
View File
@@ -7,7 +7,6 @@ import findNodeHandle from '../../modules/findNodeHandle';
import StyleSheet from '../../apis/StyleSheet';
import StyleSheetPropType from '../../propTypes/StyleSheetPropType';
import TextInputStylePropTypes from './TextInputStylePropTypes';
import TextareaAutosize from 'react-textarea-autosize';
import TextInputState from './TextInputState';
import ViewPropTypes from '../View/ViewPropTypes';
import { bool, func, number, oneOf, shape, string } from 'prop-types';
@@ -74,7 +73,6 @@ class TextInput extends Component {
'web-search'
]),
maxLength: number,
maxNumberOfLines: number,
multiline: bool,
numberOfLines: number,
onBlur: func,
@@ -143,13 +141,13 @@ class TextInput extends Component {
autoCorrect,
editable,
keyboardType,
maxNumberOfLines,
multiline,
numberOfLines,
secureTextEntry,
style,
/* eslint-disable */
blurOnSubmit,
clearButtonMode,
clearTextOnFocus,
dataDetectorTypes,
enablesReturnKeyAutomatically,
@@ -197,7 +195,7 @@ class TextInput extends Component {
type = 'password';
}
const component = multiline ? TextareaAutosize : 'input';
const component = multiline ? 'textarea' : 'input';
Object.assign(otherProps, {
autoCorrect: autoCorrect ? 'on' : 'off',
@@ -213,8 +211,7 @@ class TextInput extends Component {
});
if (multiline) {
otherProps.maxRows = maxNumberOfLines || numberOfLines;
otherProps.minRows = numberOfLines;
otherProps.rows = numberOfLines;
} else {
otherProps.type = type;
}
-4
View File
@@ -5254,10 +5254,6 @@ react-test-renderer@^15.5.4:
fbjs "^0.8.9"
object-assign "^4.1.0"
react-textarea-autosize@^4.0.4:
version "4.0.5"
resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-4.0.5.tgz#55379f6a6fa575fc87d1b8de2756e57e3b6c995d"
react-timer-mixin@^0.13.3:
version "0.13.3"
resolved "https://registry.yarnpkg.com/react-timer-mixin/-/react-timer-mixin-0.13.3.tgz#0da8b9f807ec07dc3e854d082c737c65605b3d22"