From 46943b64c6b8be3c592f2496744cfb028f09bded Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Wed, 3 May 2017 03:08:21 +0900 Subject: Reset textarea height when press submit key (#2681) * Reset textarea height when press submit key * dry * DON'T NEED props --- .../javascripts/components/components/autosuggest_textarea.jsx | 5 ++++- .../components/features/compose/components/compose_form.jsx | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/components/components/autosuggest_textarea.jsx b/app/assets/javascripts/components/components/autosuggest_textarea.jsx index d548eeeca..9a4d5b7e3 100644 --- a/app/assets/javascripts/components/components/autosuggest_textarea.jsx +++ b/app/assets/javascripts/components/components/autosuggest_textarea.jsx @@ -58,7 +58,6 @@ class AutosuggestTextarea extends React.Component { } // auto-resize textarea - e.target.style.height = 'auto'; e.target.style.height = `${e.target.scrollHeight}px`; this.props.onChange(e); @@ -147,6 +146,10 @@ class AutosuggestTextarea extends React.Component { } } + reset () { + this.textarea.style.height = 'auto'; + } + render () { const { value, suggestions, disabled, placeholder, onKeyUp } = this.props; const { suggestionsHidden, selectedSuggestion } = this.state; diff --git a/app/assets/javascripts/components/features/compose/components/compose_form.jsx b/app/assets/javascripts/components/features/compose/components/compose_form.jsx index 7955aaba9..6bc811160 100644 --- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx @@ -44,12 +44,12 @@ class ComposeForm extends React.PureComponent { handleKeyDown (e) { if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) { - this.props.onSubmit(); + this.handleSubmit(); } } handleSubmit () { - this.autosuggestTextarea.textarea.style.height = "auto"; + this.autosuggestTextarea.reset(); this.props.onSubmit(); } -- cgit