fix: submit button is not clickable on challenge completion modal

This commit is contained in:
Darth Skywalker
2017-09-02 12:13:07 +05:30
parent 1126bf7004
commit 64806f2a3b

View File

@ -26,13 +26,13 @@ const mapStateToProps = createSelector(
const mapDispatchToProps = function(dispatch) { const mapDispatchToProps = function(dispatch) {
const dispatchers = { const dispatchers = {
close: () => dispatch(closeChallengeModal()), close: () => dispatch(closeChallengeModal()),
submitChallenge: (e) => { handleKeypress: (e) => {
if ( if (e.keyCode === 13 && (e.ctrlKey || e.meta)) {
e.keyCode === 13 &&
(e.ctrlKey || e.meta)
) {
dispatch(submitChallenge()); dispatch(submitChallenge());
} }
},
submitChallenge: () => {
dispatch(submitChallenge());
} }
}; };
return () => dispatchers; return () => dispatchers;
@ -40,6 +40,7 @@ const mapDispatchToProps = function(dispatch) {
const propTypes = { const propTypes = {
close: PropTypes.func.isRequired, close: PropTypes.func.isRequired,
handleKeypress: PropTypes.func.isRequired,
isOpen: PropTypes.bool, isOpen: PropTypes.bool,
message: PropTypes.string, message: PropTypes.string,
submitChallenge: PropTypes.func.isRequired submitChallenge: PropTypes.func.isRequired
@ -51,6 +52,7 @@ export class CompletionModal extends PureComponent {
close, close,
isOpen, isOpen,
submitChallenge, submitChallenge,
handleKeypress,
message message
} = this.props; } = this.props;
return ( return (
@ -59,7 +61,7 @@ export class CompletionModal extends PureComponent {
dialogClassName={ `${ns}-success-modal` } dialogClassName={ `${ns}-success-modal` }
keyboard={ true } keyboard={ true }
onHide={ close } onHide={ close }
onKeyDown={ isOpen ? submitChallenge : noop } onKeyDown={ isOpen ? handleKeypress : noop }
show={ isOpen } show={ isOpen }
> >
<Modal.Header <Modal.Header