Skip to content

Commit f132c3c

Browse files
pachukaoliviertassinari
authored andcommitted
[TextField] Pass rowsMin prop to underlying abstractions (#15411)
* Added rowsMin prop on components that are abstractions of the TextField component and updated relevant typescript types. * Updated TextField demos with an example where minRows = 2 and maxRows = infinity. (Starts at fixed height, then grows as user enters more text). * Updated docs * remove the new demos
1 parent bebd52a commit f132c3c

File tree

11 files changed

+25
-0
lines changed

11 files changed

+25
-0
lines changed

packages/material-ui/src/FilledInput/FilledInput.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ FilledInput.propTypes = {
243243
* Maximum number of rows to display when multiline option is set to true.
244244
*/
245245
rowsMax: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
246+
/**
247+
* Minimum number of rows to display when multiline option is set to true.
248+
*/
249+
rowsMin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
246250
/**
247251
* Start `InputAdornment` for this component.
248252
*/

packages/material-ui/src/Input/Input.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ Input.propTypes = {
211211
* Maximum number of rows to display when multiline option is set to true.
212212
*/
213213
rowsMax: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
214+
/**
215+
* Minimum number of rows to display when multiline option is set to true.
216+
*/
217+
rowsMin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
214218
/**
215219
* Start `InputAdornment` for this component.
216220
*/

packages/material-ui/src/InputBase/InputBase.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface InputBaseProps
3535
}) => React.ReactNode;
3636
rows?: string | number;
3737
rowsMax?: string | number;
38+
rowsMin?: string | number;
3839
startAdornment?: React.ReactNode;
3940
type?: string;
4041
value?: unknown;

packages/material-ui/src/InputBase/Textarea.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface TextareaProps
1111
disabled?: boolean;
1212
rows?: string | number;
1313
rowsMax?: string | number;
14+
rowsMin?: string | number;
1415
textareaRef?: React.Ref<any> | React.RefObject<any>;
1516
value?: unknown;
1617
}

packages/material-ui/src/OutlinedInput/OutlinedInput.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ OutlinedInput.propTypes = {
214214
* Maximum number of rows to display when multiline option is set to true.
215215
*/
216216
rowsMax: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
217+
/**
218+
* Minimum number of rows to display when multiline option is set to true.
219+
*/
220+
rowsMin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
217221
/**
218222
* Start `InputAdornment` for this component.
219223
*/

packages/material-ui/src/TextField/TextField.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface BaseTextFieldProps
3131
required?: boolean;
3232
rows?: string | number;
3333
rowsMax?: string | number;
34+
rowsMin?: string | number;
3435
select?: boolean;
3536
SelectProps?: Partial<SelectProps>;
3637
type?: string;

packages/material-ui/src/TextField/TextField.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const TextField = React.forwardRef(function TextField(props, ref) {
8484
required,
8585
rows,
8686
rowsMax,
87+
rowsMin,
8788
select,
8889
SelectProps,
8990
type,
@@ -130,6 +131,7 @@ const TextField = React.forwardRef(function TextField(props, ref) {
130131
name={name}
131132
rows={rows}
132133
rowsMax={rowsMax}
134+
rowsMin={rowsMin}
133135
type={type}
134136
value={value}
135137
id={id}
@@ -294,6 +296,10 @@ TextField.propTypes = {
294296
* Maximum number of rows to display when multiline option is set to true.
295297
*/
296298
rowsMax: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
299+
/**
300+
* Minimum number of rows to display when multiline option is set to true.
301+
*/
302+
rowsMin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
297303
/**
298304
* Render a [`Select`](/api/select/) element while passing the Input element to `Select` as `input` parameter.
299305
* If this option is set you must pass the options of the select as children.

pages/api/filled-input.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import FilledInput from '@material-ui/core/FilledInput';
4141
| <span class="prop-name">required</span> | <span class="prop-type">bool</span> | | If `true`, the `input` element will be required. |
4242
| <span class="prop-name">rows</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Number of rows to display when multiline option is set to true. |
4343
| <span class="prop-name">rowsMax</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Maximum number of rows to display when multiline option is set to true. |
44+
| <span class="prop-name">rowsMin</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Minimum number of rows to display when multiline option is set to true. |
4445
| <span class="prop-name">startAdornment</span> | <span class="prop-type">node</span> | | Start `InputAdornment` for this component. |
4546
| <span class="prop-name">type</span> | <span class="prop-type">string</span> | | Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). |
4647
| <span class="prop-name">value</span> | <span class="prop-type">any</span> | | The value of the `input` element, required for a controlled component. |

pages/api/input.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import Input from '@material-ui/core/Input';
4141
| <span class="prop-name">required</span> | <span class="prop-type">bool</span> | | If `true`, the `input` element will be required. |
4242
| <span class="prop-name">rows</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Number of rows to display when multiline option is set to true. |
4343
| <span class="prop-name">rowsMax</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Maximum number of rows to display when multiline option is set to true. |
44+
| <span class="prop-name">rowsMin</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Minimum number of rows to display when multiline option is set to true. |
4445
| <span class="prop-name">startAdornment</span> | <span class="prop-type">node</span> | | Start `InputAdornment` for this component. |
4546
| <span class="prop-name">type</span> | <span class="prop-type">string</span> | | Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). |
4647
| <span class="prop-name">value</span> | <span class="prop-type">any</span> | | The value of the `input` element, required for a controlled component. |

pages/api/outlined-input.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import OutlinedInput from '@material-ui/core/OutlinedInput';
4242
| <span class="prop-name">required</span> | <span class="prop-type">bool</span> | | If `true`, the `input` element will be required. |
4343
| <span class="prop-name">rows</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Number of rows to display when multiline option is set to true. |
4444
| <span class="prop-name">rowsMax</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Maximum number of rows to display when multiline option is set to true. |
45+
| <span class="prop-name">rowsMin</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Minimum number of rows to display when multiline option is set to true. |
4546
| <span class="prop-name">startAdornment</span> | <span class="prop-type">node</span> | | Start `InputAdornment` for this component. |
4647
| <span class="prop-name">type</span> | <span class="prop-type">string</span> | | Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). |
4748
| <span class="prop-name">value</span> | <span class="prop-type">any</span> | | The value of the `input` element, required for a controlled component. |

pages/api/text-field.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ For advanced cases, please look at the source of TextField by clicking on the
7070
| <span class="prop-name">required</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the label is displayed as required and the `input` element` will be required. |
7171
| <span class="prop-name">rows</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Number of rows to display when multiline option is set to true. |
7272
| <span class="prop-name">rowsMax</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Maximum number of rows to display when multiline option is set to true. |
73+
| <span class="prop-name">rowsMin</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br></span> | | Minimum number of rows to display when multiline option is set to true. |
7374
| <span class="prop-name">select</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | Render a [`Select`](/api/select/) element while passing the Input element to `Select` as `input` parameter. If this option is set you must pass the options of the select as children. |
7475
| <span class="prop-name">SelectProps</span> | <span class="prop-type">object</span> | | Properties applied to the [`Select`](/api/select/) element. |
7576
| <span class="prop-name">type</span> | <span class="prop-type">string</span> | | Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). |

0 commit comments

Comments
 (0)