-
-
Notifications
You must be signed in to change notification settings - Fork 207
Fix for ctrl key having no impact on submit process #181
Conversation
@@ -35,18 +35,46 @@ const options = { | |||
required: ['solution', 'githubLink'] | |||
}; | |||
|
|||
var keysDown = { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -35,18 +35,46 @@ const options = { | |||
required: ['solution', 'githubLink'] | |||
}; | |||
|
|||
var keysDown = { | |||
Control: 0, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
handleKeyDown(e) { | ||
if (e.key === 'Control') { | ||
keysDown.Control = 1; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -58,7 +86,7 @@ export class ProjectForm extends PureComponent { | |||
formFields={isFrontEnd ? frontEndFields : backEndFields} | |||
id={isFrontEnd ? 'front-end-form' : 'back-end-form'} | |||
options={options} | |||
submit={this.handleSubmit} | |||
submit={this.handleSubmit.bind(this)} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
handleKeyDown(e) { | ||
if (e.key === 'Control') { | ||
keysDown.Control = 1; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
e03174f
to
ee3ec38
Compare
I've amended my commit as per requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there @joops75
} | ||
handleKeyDown(e) { | ||
if (e.key === 'Control') { | ||
this.setState({ keysDown: { ...this.state.keysDown, Control: true } }); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
handleSubmit(values) { | ||
if ( | ||
this.state.keysDown.Control && this.state.keysDown.Enter || |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ee3ec38
to
5f36ac5
Compare
5f36ac5
to
3623af3
Compare
@Bouncey Re-amended commit. Hopefully this sorts it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @joops75 for sticking with this!
No problem @Bouncey . Thanks for all the feedback! |
A fix for issue 67. Keydown and keyup event listeners added to determine when enter and ctrl are pressed down. 'If' statement added to the handleSubmit function to check these two keys are pressed before submitting. This statement also covers the case that enter is not pressed and so the mouse must have been clicked to submit the form.
Additionally, the handleSubmit function was changed from an arrow function to match the formatting of the other functions.
Tested on my machine (Windows 7, Firefox Quantum 64-bit).