diff --git a/react/components/ExpandingTextArea/index.jsx b/react/components/ExpandingTextArea/index.jsx index 182af876..db83c5d8 100644 --- a/react/components/ExpandingTextArea/index.jsx +++ b/react/components/ExpandingTextArea/index.jsx @@ -2,31 +2,32 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; class ExpandingTextarea extends Component { + constructor (props) { + super(props); + this._handleChange = this._handleChange.bind(this); + } componentDidMount () { this.adjustTextarea({}); } - + _handleChange (event) { + const { onChange } = this.props; + if (onChange) onChange(event); + this.adjustTextarea(event); + } + adjustTextarea ({ target = this.el }) { + target.style.height = 0; + target.style.height = `${target.scrollHeight}px`; + } render () { const { ...rest } = this.props; return (