Skip to content

Commit

Permalink
[TextField] Add support for minRows (#27293)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Jul 17, 2021
1 parent 6d08a55 commit a74def3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/pages/api-docs/text-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The `MuiTextField` name can be used for providing [default props](/customization
| <span class="prop-name">label</span> | <span class="prop-type">node</span> | | The label content. |
| <span class="prop-name">margin</span> | <span class="prop-type">'dense'<br>&#124;&nbsp;'none'<br>&#124;&nbsp;'normal'</span> | | If `dense` or `normal`, will adjust vertical spacing of this and contained components. |
| <span class="prop-name">maxRows</span> | <span class="prop-type">number<br>&#124;&nbsp;string</span> | | Maximum number of rows to display when multiline option is set to true. |
| <span class="prop-name">minRows</span> | <span class="prop-type">number<br>&#124;&nbsp;string</span> | | Minimum number of rows to display. |
| <span class="prop-name">multiline</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, a textarea element will be rendered instead of an input. |
| <span class="prop-name">name</span> | <span class="prop-type">string</span> | | Name attribute of the `input` element. |
| <span class="prop-name">onChange</span> | <span class="prop-type">func</span> | | Callback fired when the value is changed.<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback. You can pull out the new value by accessing `event.target.value` (string). |
Expand Down
5 changes: 5 additions & 0 deletions packages/material-ui/src/TextField/TextField.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface BaseTextFieldProps
required?: boolean;
/**
* Number of rows to display when multiline option is set to true.
* @deprecated Use `minRows` instead.
*/
rows?: string | number;
/**
Expand All @@ -107,6 +108,10 @@ export interface BaseTextFieldProps
* Maximum number of rows to display when multiline option is set to true.
*/
maxRows?: string | number;
/**
* Minimum number of rows to display.
*/
minRows?: string | number;
/**
* 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.
Expand Down
7 changes: 7 additions & 0 deletions packages/material-ui/src/TextField/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const TextField = React.forwardRef(function TextField(props, ref) {
rows,
rowsMax,
maxRows,
minRows,
select = false,
SelectProps,
type,
Expand Down Expand Up @@ -140,6 +141,7 @@ const TextField = React.forwardRef(function TextField(props, ref) {
rows={rows}
rowsMax={rowsMax}
maxRows={maxRows}
minRows={minRows}
type={type}
value={value}
id={id}
Expand Down Expand Up @@ -293,6 +295,10 @@ TextField.propTypes = {
* Maximum number of rows to display when multiline option is set to true.
*/
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
* Minimum number of rows to display.
*/
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
* If `true`, a textarea element will be rendered instead of an input.
*/
Expand Down Expand Up @@ -326,6 +332,7 @@ TextField.propTypes = {
required: PropTypes.bool,
/**
* Number of rows to display when multiline option is set to true.
* @deprecated Use `minRows` instead.
*/
rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
Expand Down

0 comments on commit a74def3

Please sign in to comment.