import React from 'react'; export default class AutoheightInput extends React.Component { constructor(props) { super(props); this.inputChange = this.inputChange.bind(this); } componentDidMount() { this.updateHeight(); } /** * Update the input height based on the content * @return {[type]} [description] */ updateHeight() { if (!this.refs.input) { return; } const el = this.refs.input; el.style.height = 'auto'; el.style.height = el.scrollHeight + 'px'; } inputChange() { this.updateHeight(); if (this.props.onChange) { this.props.onChange(this.refs.input.value); } } /** * Return the text stored in the input control * @return {[type]} [description] */ getText() { return this.refs.input.value; } setText(txt) { this.refs.input.value = txt; this.inputChange(); } /** * Set the focus on the control * @return {[type]} [description] */ focus() { this.refs.input.focus(); } render() { return (