diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-03-14 14:36:40 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-03-21 09:49:29 -0400 |
commit | f134df04b024dcf8310a02558e58afdf2a6ed94c (patch) | |
tree | c6809762d7c2bd42f89f698629225bf40c2fb613 /webapp/components/suggestion/suggestion_box.jsx | |
parent | 85837efe06a93b38e449c750108a4105cc629611 (diff) | |
download | chat-f134df04b024dcf8310a02558e58afdf2a6ed94c.tar.gz chat-f134df04b024dcf8310a02558e58afdf2a6ed94c.tar.bz2 chat-f134df04b024dcf8310a02558e58afdf2a6ed94c.zip |
Switched Textbox to use a TextareaAutosize and removed custom resizing code
Diffstat (limited to 'webapp/components/suggestion/suggestion_box.jsx')
-rw-r--r-- | webapp/components/suggestion/suggestion_box.jsx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/webapp/components/suggestion/suggestion_box.jsx b/webapp/components/suggestion/suggestion_box.jsx index e3ec63194..b7f0e3a36 100644 --- a/webapp/components/suggestion/suggestion_box.jsx +++ b/webapp/components/suggestion/suggestion_box.jsx @@ -3,11 +3,14 @@ import $ from 'jquery'; import ReactDOM from 'react-dom'; + import Constants from 'utils/constants.jsx'; import * as GlobalActions from 'action_creators/global_actions.jsx'; import SuggestionStore from 'stores/suggestion_store.jsx'; import * as Utils from 'utils/utils.jsx'; +import TextareaAutosize from 'react-textarea-autosize'; + const KeyCodes = Constants.KeyCodes; import React from 'react'; @@ -44,7 +47,13 @@ export default class SuggestionBox extends React.Component { getTextbox() { // this is to support old code that looks at the input/textarea DOM nodes - return ReactDOM.findDOMNode(this.refs.textbox); + let textbox = this.refs.textbox; + + if (!(textbox instanceof HTMLElement)) { + textbox = ReactDOM.findDOMNode(textbox); + } + + return textbox; } handleDocumentClick(e) { @@ -132,7 +141,8 @@ export default class SuggestionBox extends React.Component { ); } else if (this.props.type === 'textarea') { textbox = ( - <textarea + <TextareaAutosize + id={this.suggestionId} ref='textbox' {...newProps} /> @@ -163,5 +173,6 @@ SuggestionBox.propTypes = { // explicitly name any input event handlers we override and need to manually call onChange: React.PropTypes.func, - onKeyDown: React.PropTypes.func + onKeyDown: React.PropTypes.func, + onHeightChange: React.PropTypes.func }; |