diff --git a/packages/core/src/components/forms/textArea.tsx b/packages/core/src/components/forms/textArea.tsx index c7fcfda241..7d39d5128c 100644 --- a/packages/core/src/components/forms/textArea.tsx +++ b/packages/core/src/components/forms/textArea.tsx @@ -54,9 +54,16 @@ export interface ITextAreaState { /* istanbul ignore next */ export class TextArea extends React.PureComponent { public static displayName = `${DISPLAYNAME_PREFIX}.TextArea`; - public state: ITextAreaState = {}; + private internalTextAreaRef: HTMLTextAreaElement; + public componentDidMount() { + if (this.props.growVertically) { + this.setState({ + height: this.internalTextAreaRef.scrollHeight, + }); + } + } public render() { const { className, fill, inputRef, intent, large, small, growVertically, ...htmlProps } = this.props; @@ -87,7 +94,7 @@ export class TextArea extends React.PureComponent ); @@ -104,4 +111,12 @@ export class TextArea extends React.PureComponent { + this.internalTextAreaRef = ref; + if (this.props.inputRef != null) { + this.props.inputRef(ref); + } + }; } diff --git a/packages/core/test/forms/textAreaTests.tsx b/packages/core/test/forms/textAreaTests.tsx index 83084f619b..3a643533f3 100644 --- a/packages/core/test/forms/textAreaTests.tsx +++ b/packages/core/test/forms/textAreaTests.tsx @@ -51,4 +51,18 @@ describe("