From f134df04b024dcf8310a02558e58afdf2a6ed94c Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Mon, 14 Mar 2016 14:36:40 -0400
Subject: Switched Textbox to use a TextareaAutosize and removed custom
 resizing code

---
 webapp/components/suggestion/suggestion_box.jsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'webapp/components/suggestion/suggestion_box.jsx')

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
 };
-- 
cgit v1.2.3-1-g7c22

