fix: allow ctrl+enter to submit video lessons (#38898)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Tom
2020-05-26 08:47:36 -05:00
committed by Mrugesh Mohapatra
parent 74430b3ec3
commit 911ba72106

View File

@ -8,6 +8,7 @@ import { graphql } from 'gatsby';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import YouTube from 'react-youtube'; import YouTube from 'react-youtube';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { ObserveKeys } from 'react-hotkeys';
// Local Utilities // Local Utilities
import PrismFormatted from '../components/PrismFormatted'; import PrismFormatted from '../components/PrismFormatted';
@ -165,6 +166,9 @@ export class Project extends Component {
const blockNameTitle = `${blockName} - ${title}`; const blockNameTitle = `${blockName} - ${title}`;
return ( return (
<Hotkeys <Hotkeys
executeChallenge={() => {
this.handleSubmit(solution, openCompletionModal);
}}
innerRef={c => (this._container = c)} innerRef={c => (this._container = c)}
introPath={introPath} introPath={introPath}
nextChallengePath={nextChallengePath} nextChallengePath={nextChallengePath}
@ -213,9 +217,12 @@ export class Project extends Component {
<ChallengeDescription description={description} /> <ChallengeDescription description={description} />
<PrismFormatted text={text} /> <PrismFormatted text={text} />
<Spacer /> <Spacer />
<ObserveKeys>
<div className='video-quiz-options'> <div className='video-quiz-options'>
{answers.map((option, index) => ( {answers.map((option, index) => (
<label className='video-quiz-option-label'> // answers are static and have no natural id property, so
// index should be fine as a key:
<label className='video-quiz-option-label' key={index}>
<input <input
checked={this.state.selectedOption === index} checked={this.state.selectedOption === index}
className='video-quiz-input-hidden' className='video-quiz-input-hidden'
@ -236,6 +243,7 @@ export class Project extends Component {
</label> </label>
))} ))}
</div> </div>
</ObserveKeys>
<Spacer /> <Spacer />
<div <div
style={{ style={{