From c48772fd3f12fac1ee28c8cfc521daedcb4d26c9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 26 May 2017 18:22:23 +0200 Subject: [PATCH] Introduce react-textarea-autosize instead of using style.height side effects (#3334) --- .../mastodon/components/autosuggest_textarea.js | 13 +++---------- .../features/compose/components/compose_form.js | 1 - package.json | 1 + yarn.lock | 6 ++++++ 4 files changed, 10 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 (
-