Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 13, 2019
1 parent cbebea6 commit dde4273
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/pages/api/input-base.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ It contains a load of style reset and some state logic.
| <span class="prop-name">required</span> | <span class="prop-type">bool</span> | | If `true`, the `input` element will be required. |
| <span class="prop-name">rows</span> | <span class="prop-type">string<br>&#124;&nbsp;number</span> | | Number of rows to display when multiline option is set to true. |
| <span class="prop-name">rowsMax</span> | <span class="prop-type">string<br>&#124;&nbsp;number</span> | | Maximum number of rows to display when multiline option is set to true. |
| <span class="prop-name">rowsMin</span> | <span class="prop-type">string<br>&#124;&nbsp;number</span> | | Minimum number of rows to display when multiline option is set to true. |
| <span class="prop-name">startAdornment</span> | <span class="prop-type">node</span> | | Start `InputAdornment` for this component. |
| <span class="prop-name">type</span> | <span class="prop-type">string</span> | <span class="prop-default">'text'</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). |
| <span class="prop-name">value</span> | <span class="prop-type">any</span> | | The value of the `input` element, required for a controlled component. |
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/api/textarea-autosize.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ You can learn more about the difference by [reading this guide](/guides/minimizi

| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">rows</span> | <span class="prop-type">string<br>&#124;&nbsp;number</span> | | Minimum number of rows to display. |
| <span class="prop-name">rows</span> | <span class="prop-type">string<br>&#124;&nbsp;number</span> | | Use `rowsMin` instead. The prop will be removed in v5. |
| <span class="prop-name">rowsMax</span> | <span class="prop-type">string<br>&#124;&nbsp;number</span> | | Maximum number of rows to display. |
| <span class="prop-name">rowsMin</span> | <span class="prop-type">string<br>&#124;&nbsp;number</span> | <span class="prop-default">1</span> | Minimum number of rows to display. |

The `ref` is forwarded to the root element.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import React from 'react';
import TextareaAutosize from '@material-ui/core/TextareaAutosize';

export default function MinHeightTextarea() {
return <TextareaAutosize aria-label="minimum height" rows={3} placeholder="Minimum 3 rows" />;
return <TextareaAutosize aria-label="minimum height" rowsMin={3} placeholder="Minimum 3 rows" />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import React from 'react';
import TextareaAutosize from '@material-ui/core/TextareaAutosize';

export default function MinHeightTextarea() {
return <TextareaAutosize aria-label="minimum height" rows={3} placeholder="Minimum 3 rows" />;
return <TextareaAutosize aria-label="minimum height" rowsMin={3} placeholder="Minimum 3 rows" />;
}
7 changes: 0 additions & 7 deletions packages/material-ui/src/InputBase/InputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,10 @@ InputBase.propTypes = {
*/
rowsMax: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
<<<<<<< HEAD
=======
* Minimum number of rows to display when multiline option is set to true.
*/
rowsMin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
/**
* Should be `true` when the component hosts a select.
*/
select: PropTypes.bool,
/**
>>>>>>> Add rowsMin
* Start `InputAdornment` for this component.
*/
startAdornment: PropTypes.node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';

export interface TextareaAutosizeProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
rowsMax?: string | number;
rowsMin?: string | number;
}

declare const TextareaAutosize: React.ComponentType<
Expand Down
8 changes: 4 additions & 4 deletions packages/material-ui/src/TextareaAutosize/TextareaAutosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const styles = {
const TextareaAutosize = React.forwardRef(function TextareaAutosize(props, ref) {
const { onChange, rows, rowsMax, rowsMin: rowsMinProp = 1, style, value, ...other } = props;

const rowsMin = rowsMinProp || rows;
const rowsMin = rows || rowsMinProp;

const { current: isControlled } = React.useRef(value != null);
const inputRef = React.useRef(null);
Expand Down Expand Up @@ -62,10 +62,10 @@ const TextareaAutosize = React.forwardRef(function TextareaAutosize(props, ref)
// The height of the outer content
let outerHeight = innerHeight;

if (rowsMin != null) {
if (rowsMin) {
outerHeight = Math.max(Number(rowsMin) * singleRowHeight, outerHeight);
}
if (rowsMax != null) {
if (rowsMax) {
outerHeight = Math.min(Number(rowsMax) * singleRowHeight, outerHeight);
}
outerHeight = Math.max(outerHeight, singleRowHeight);
Expand Down Expand Up @@ -161,7 +161,7 @@ TextareaAutosize.propTypes = {
*/
placeholder: PropTypes.string,
/**
* Use `rowsMin` instead
* Use `rowsMin` instead. The prop will be removed in v5.
*
* @deprecated
*/
Expand Down

0 comments on commit dde4273

Please sign in to comment.