Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Fix for ctrl key having no impact on submit process #181

Merged
merged 1 commit into from
Jun 20, 2018

Conversation

joops75
Copy link

@joops75 joops75 commented Jun 15, 2018

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).

@@ -35,18 +35,46 @@ const options = {
required: ['solution', 'githubLink']
};

var keysDown = {

This comment was marked as spam.

@@ -35,18 +35,46 @@ const options = {
required: ['solution', 'githubLink']
};

var keysDown = {
Control: 0,

This comment was marked as spam.

}
handleKeyDown(e) {
if (e.key === 'Control') {
keysDown.Control = 1;

This comment was marked as spam.

@@ -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.

}
handleKeyDown(e) {
if (e.key === 'Control') {
keysDown.Control = 1;

This comment was marked as spam.

@joops75
Copy link
Author

joops75 commented Jun 18, 2018

I've amended my commit as per requests.

Copy link
Member

@Bouncey Bouncey left a 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.

}
handleSubmit(values) {
if (
this.state.keysDown.Control && this.state.keysDown.Enter ||

This comment was marked as spam.

@joops75
Copy link
Author

joops75 commented Jun 19, 2018

@Bouncey Re-amended commit. Hopefully this sorts it!

Copy link
Member

@Bouncey Bouncey left a 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!

@Bouncey Bouncey merged commit 069f551 into freeCodeCamp:master Jun 20, 2018
@joops75
Copy link
Author

joops75 commented Jun 20, 2018

No problem @Bouncey . Thanks for all the feedback!

@joops75 joops75 deleted the fix/ctrl-enter-submit branch June 20, 2018 11:08
Bouncey pushed a commit to Bouncey/learn that referenced this pull request Jul 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants