Disable toot button when above 500 characters (#2088)
* Disable toot button when above 500 characters * Consider multibyte characters * Consider spoiler_textgh/stable
parent
9783d8b6c0
commit
f23281e31e
|
@ -131,6 +131,7 @@ const ComposeForm = React.createClass({
|
||||||
render () {
|
render () {
|
||||||
const { intl, needsPrivacyWarning, mentionedDomains, onPaste } = this.props;
|
const { intl, needsPrivacyWarning, mentionedDomains, onPaste } = this.props;
|
||||||
const disabled = this.props.is_submitting;
|
const disabled = this.props.is_submitting;
|
||||||
|
const text = [this.props.spoiler_text, this.props.text].join('');
|
||||||
|
|
||||||
let publishText = '';
|
let publishText = '';
|
||||||
let privacyWarning = '';
|
let privacyWarning = '';
|
||||||
|
@ -197,8 +198,8 @@ const ComposeForm = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ display: 'flex' }}>
|
<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', marginRight: '16px', lineHeight: '36px' }}><CharacterCounter max={500} text={text} /></div>
|
||||||
<div style={{ paddingTop: '10px' }}><Button text={publishText} onClick={this.handleSubmit} disabled={disabled} /></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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in New Issue