Changeset View
Changeset View
Standalone View
Standalone View
web/chat/chat-input-text-area.react.js
// @flow | // @flow | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import css from './chat-input-bar.css'; | import css from './chat-input-bar.css'; | ||||
type BaseProps = { | type BaseProps = { | ||||
+send?: () => mixed, | +send?: () => mixed, | ||||
+escape?: () => void, | +escape?: () => void, | ||||
+focus: boolean, | +focus: boolean, | ||||
+currentText: string, | +currentText: string, | ||||
+setCurrentText: (text: string) => void, | +setCurrentText: (text: string) => void, | ||||
+onChangePosition: any => void, | |||||
}; | }; | ||||
type Props = { | type Props = { | ||||
...BaseProps, | ...BaseProps, | ||||
}; | }; | ||||
class ChatInputTextArea extends React.PureComponent<Props> { | class ChatInputTextArea extends React.PureComponent<Props> { | ||||
textarea: ?HTMLTextAreaElement; | textarea: ?HTMLTextAreaElement; | ||||
Show All 12 Lines | class ChatInputTextArea extends React.PureComponent<Props> { | ||||
updateHeight() { | updateHeight() { | ||||
const textarea = this.textarea; | const textarea = this.textarea; | ||||
if (textarea) { | if (textarea) { | ||||
textarea.style.height = 'auto'; | textarea.style.height = 'auto'; | ||||
const newHeight = Math.min(textarea.scrollHeight, 150); | const newHeight = Math.min(textarea.scrollHeight, 150); | ||||
textarea.style.height = `${newHeight}px`; | textarea.style.height = `${newHeight}px`; | ||||
} | } | ||||
this.props.onChangePosition(); | |||||
} | } | ||||
render() { | render() { | ||||
return ( | return ( | ||||
<div className={css.inputBarTextInput}> | <div className={css.inputBarTextInput}> | ||||
<textarea | <textarea | ||||
rows="1" | rows="1" | ||||
placeholder="Type your message" | placeholder="Type your message" | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |