Focus the submit button on the boost modal (#3494)

Focus the submit button when boost modal is opened.
This commit is contained in:
unarist 2017-06-01 11:20:10 +09:00 committed by Eugen Rochko
parent 1066fd1ab5
commit 158d6c85da

View file

@ -27,6 +27,10 @@ class BoostModal extends ImmutablePureComponent {
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
}; };
componentDidMount() {
this.button.focus();
}
handleReblog = () => { handleReblog = () => {
this.props.onReblog(this.props.status); this.props.onReblog(this.props.status);
this.props.onClose(); this.props.onClose();
@ -40,6 +44,10 @@ class BoostModal extends ImmutablePureComponent {
} }
} }
setRef = (c) => {
this.button = c;
}
render () { render () {
const { status, intl, onClose } = this.props; const { status, intl, onClose } = this.props;
@ -67,7 +75,7 @@ class BoostModal extends ImmutablePureComponent {
<div className='boost-modal__action-bar'> <div className='boost-modal__action-bar'>
<div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} /></div> <div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} /></div>
<Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} /> <Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} ref={this.setRef} />
</div> </div>
</div> </div>
); );