about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-05-26 18:22:23 +0200
committerGitHub <noreply@github.com>2017-05-26 18:22:23 +0200
commitc48772fd3f12fac1ee28c8cfc521daedcb4d26c9 (patch)
tree3e880df1bd061304231843016306edcb1c020269 /app/javascript
parent860e257a6895030db112a3e81f6d0a3e398a7b74 (diff)
Introduce react-textarea-autosize instead of using style.height side effects (#3334)
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/components/autosuggest_textarea.js13
-rw-r--r--app/javascript/mastodon/features/compose/components/compose_form.js1
2 files changed, 3 insertions, 11 deletions
diff --git a/app/javascript/mastodon/components/autosuggest_textarea.js b/app/javascript/mastodon/components/autosuggest_textarea.js
index 9372e6146..10efd17fb 100644
--- a/app/javascript/mastodon/components/autosuggest_textarea.js
+++ b/app/javascript/mastodon/components/autosuggest_textarea.js
@@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
 import PropTypes from 'prop-types';
 import { isRtl } from '../rtl';
 import ImmutablePureComponent from 'react-immutable-pure-component';
+import Textarea from 'react-textarea-autosize';
 
 const textAtCursorMatchesToken = (str, caretPosition) => {
   let word;
@@ -69,10 +70,6 @@ class AutosuggestTextarea extends ImmutablePureComponent {
       this.props.onSuggestionsClearRequested();
     }
 
-    // auto-resize textarea
-    e.target.style.height = 'auto';
-    e.target.style.height = `${e.target.scrollHeight}px`;
-
     this.props.onChange(e);
   }
 
@@ -160,10 +157,6 @@ class AutosuggestTextarea extends ImmutablePureComponent {
     }
   }
 
-  reset () {
-    this.textarea.style.height = 'auto';
-  }
-
   render () {
     const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props;
     const { suggestionsHidden, selectedSuggestion } = this.state;
@@ -175,8 +168,8 @@ class AutosuggestTextarea extends ImmutablePureComponent {
 
     return (
       <div className='autosuggest-textarea'>
-        <textarea
-          ref={this.setTextarea}
+        <Textarea
+          inputRef={this.setTextarea}
           className='autosuggest-textarea__textarea'
           disabled={disabled}
           placeholder={placeholder}
diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js
index 43b76e353..5fa074f4b 100644
--- a/app/javascript/mastodon/features/compose/components/compose_form.js
+++ b/app/javascript/mastodon/features/compose/components/compose_form.js
@@ -67,7 +67,6 @@ class ComposeForm extends ImmutablePureComponent {
   }
 
   handleSubmit = () => {
-    this.autosuggestTextarea.reset();
     this.props.onSubmit();
   }