From 1e744bd9e8f3df7e57dab281c0553f9ef7fb0598 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 20 Jun 2018 13:38:22 +0300 Subject: message input autosize --- vnext/src/components/MessageInput.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/vnext/src/components/MessageInput.js b/vnext/src/components/MessageInput.js index 2a7eab1d..15d36309 100644 --- a/vnext/src/components/MessageInput.js +++ b/vnext/src/components/MessageInput.js @@ -5,6 +5,17 @@ import { MessageType } from './Types'; export default class MessageInput extends React.Component { constructor(props) { super(props) + this.resize = this.resize.bind(this); + this.textarea = React.createRef(); + } + componentDidMount() { + this.resize() + } + resize() { + const el = this.textarea.current; + const offset = el.offsetHeight - el.clientHeight; + const height = el.scrollHeight + offset; + el.style.height = `${height + offset}px`; } render() { const msg = this.props.data; @@ -13,7 +24,9 @@ export default class MessageInput extends React.Component {