Skip to content

Commit

Permalink
fix: textarea-item auto height scroll, close ant-design#1858
Browse files Browse the repository at this point in the history
  • Loading branch information
silentcloud authored and lixiaoyang1992 committed Apr 26, 2018
1 parent 6edbb1f commit 11cca83
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/textarea-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export default class TextareaItem extends React.Component<TextareaItemProps, Tex
focus = () => {
this.textareaRef.focus();
}

componentDidUpdate() {
if (this.props.autoHeight) {
if (this.props.autoHeight && this.state.focus) {
const textareaDom = this.textareaRef;
textareaDom.style.height = ''; // 字数减少时能自动减小高度
textareaDom.style.height = `${textareaDom.scrollHeight}px`;
Expand Down

0 comments on commit 11cca83

Please sign in to comment.