From a74def381cc4f9fe1945b268d74cfa2002271ad8 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 17 Jul 2021 12:16:01 +0200 Subject: [PATCH] [TextField] Add support for `minRows` (#27293) --- docs/pages/api-docs/text-field.md | 1 + packages/material-ui/src/TextField/TextField.d.ts | 5 +++++ packages/material-ui/src/TextField/TextField.js | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/docs/pages/api-docs/text-field.md b/docs/pages/api-docs/text-field.md index 9ed652fb415e25..67ba8828cddeb9 100644 --- a/docs/pages/api-docs/text-field.md +++ b/docs/pages/api-docs/text-field.md @@ -75,6 +75,7 @@ The `MuiTextField` name can be used for providing [default props](/customization | label | node | | The label content. | | margin | 'dense'
| 'none'
| 'normal'
| | If `dense` or `normal`, will adjust vertical spacing of this and contained components. | | maxRows | number
| string
| | Maximum number of rows to display when multiline option is set to true. | +| minRows | number
| string
| | Minimum number of rows to display. | | multiline | bool | false | If `true`, a textarea element will be rendered instead of an input. | | name | string | | Name attribute of the `input` element. | | onChange | func | | Callback fired when the value is changed.

**Signature:**
`function(event: object) => void`
*event:* The event source of the callback. You can pull out the new value by accessing `event.target.value` (string). | diff --git a/packages/material-ui/src/TextField/TextField.d.ts b/packages/material-ui/src/TextField/TextField.d.ts index 851883e7a9d50a..569bda0edbf4b7 100644 --- a/packages/material-ui/src/TextField/TextField.d.ts +++ b/packages/material-ui/src/TextField/TextField.d.ts @@ -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; /** @@ -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. diff --git a/packages/material-ui/src/TextField/TextField.js b/packages/material-ui/src/TextField/TextField.js index f53d19e040b1e0..9c63102c08db5f 100644 --- a/packages/material-ui/src/TextField/TextField.js +++ b/packages/material-ui/src/TextField/TextField.js @@ -85,6 +85,7 @@ const TextField = React.forwardRef(function TextField(props, ref) { rows, rowsMax, maxRows, + minRows, select = false, SelectProps, type, @@ -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} @@ -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. */ @@ -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]), /**