Fixed issue with enter key not working in delete post modal

Этот коммит содержится в:
Reed Garmsen
2016-01-20 13:16:53 -08:00
родитель a2fa683c1b
Коммит c408e09a04

Просмотреть файл

@@ -23,7 +23,7 @@ export default class DeletePostModal extends React.Component {
this.selectedList = null; this.selectedList = null;
this.state = { this.state = {
show: true, show: false,
post: null, post: null,
commentCount: 0, commentCount: 0,
error: '' error: ''
@@ -40,6 +40,14 @@ export default class DeletePostModal extends React.Component {
ModalStore.removeModalListener(ActionTypes.TOGGLE_DELETE_POST_MODAL, this.handleToggle); ModalStore.removeModalListener(ActionTypes.TOGGLE_DELETE_POST_MODAL, this.handleToggle);
} }
componentDidUpdate(prevProps, prevState) {
if (this.state.show && !prevState.show) {
setTimeout(() => {
$(ReactDOM.findDOMNode(this.refs.deletePostBtn)).focus();
}, 0);
}
}
handleDelete() { handleDelete() {
Client.deletePost( Client.deletePost(
this.state.post.channel_id, this.state.post.channel_id,
@@ -149,10 +157,10 @@ export default class DeletePostModal extends React.Component {
{'Cancel'} {'Cancel'}
</button> </button>
<button <button
ref='deletePostBtn'
type='button' type='button'
className='btn btn-danger' className='btn btn-danger'
onClick={this.handleDelete} onClick={this.handleDelete}
autoFocus='autofocus'
> >
{'Delete'} {'Delete'}
</button> </button>