about summary refs log tree commit diff
path: root/app/assets
diff options
context:
space:
mode:
authorTomohiro Suwa <neoen.gsn@gmail.com>2017-04-19 02:35:55 +0900
committerEugen <eugen@zeonfederated.com>2017-04-18 19:35:55 +0200
commitf23281e31ead38a1cabbb73f0dbb8b36cb38cadb (patch)
treed7bf6b63af0df32247fca09ea32048ec8db8790a /app/assets
parent9783d8b6c074c371acd466c17acf0b21f82af296 (diff)
Disable toot button when above 500 characters (#2088)
* Disable toot button when above 500 characters

* Consider multibyte characters

* Consider spoiler_text
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/components/features/compose/components/compose_form.jsx5
1 files changed, 3 insertions, 2 deletions
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 c7df22765..fad77c8e9 100644
--- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx
+++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx
@@ -131,6 +131,7 @@ const ComposeForm = React.createClass({
   render () {
     const { intl, needsPrivacyWarning, mentionedDomains, onPaste } = this.props;
     const disabled = this.props.is_submitting;
+    const text = [this.props.spoiler_text, this.props.text].join('');
 
     let publishText    = '';
     let privacyWarning = '';
@@ -197,8 +198,8 @@ const ComposeForm = React.createClass({
           </div>
 
           <div style={{ display: 'flex' }}>
-            <div style={{ paddingTop: '10px', marginRight: '16px', lineHeight: '36px' }}><CharacterCounter max={500} text={[this.props.spoiler_text, this.props.text].join('')} /></div>
-            <div style={{ paddingTop: '10px' }}><Button text={publishText} onClick={this.handleSubmit} disabled={disabled} /></div>
+            <div style={{ paddingTop: '10px', marginRight: '16px', lineHeight: '36px' }}><CharacterCounter max={500} text={text} /></div>
+            <div style={{ paddingTop: '10px' }}><Button text={publishText} onClick={this.handleSubmit} disabled={disabled || text.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length > 500} /></div>
           </div>
         </div>
       </div>