Skip to content

Commit

Permalink
fix: check onKeyUp instead of onKeyDown
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Jan 27, 2021
1 parent 5b7777b commit 1576da0
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ChallengeModalCtrl extends PureViewCtrl<unknown, ChallengeModalState> {
application!: WebApplication;
challenge!: Challenge;
onDismiss!: () => void;
submitting = false;

/** @template */
protectionsSessionDurations = ProtectionSessionDurations;
Expand Down Expand Up @@ -177,6 +178,10 @@ class ChallengeModalCtrl extends PureViewCtrl<unknown, ChallengeModalState> {
if (!this.validate()) {
return;
}
if (this.submitting) {
return;
}
this.submitting = true;
await this.setState({ processing: true });
const values: ChallengeValue[] = [];
for (const inputValue of Object.values(this.getState().values)) {
Expand All @@ -200,6 +205,7 @@ class ChallengeModalCtrl extends PureViewCtrl<unknown, ChallengeModalState> {
} else {
this.setState({ processing: false });
}
this.submitting = false;
}, 50);
}

Expand Down Expand Up @@ -378,10 +384,9 @@ function ChallengePrompts({
ctrl.state.values[prompt.id]!.value = value;
ctrl.onTextValueChange(prompt);
}}
onKeyDown={(event) => {
onKeyUp={(event) => {
if (event.key === 'Enter') {
event.preventDefault();
event.stopPropagation();
ctrl.submit();
}
}}
Expand Down

0 comments on commit 1576da0

Please sign in to comment.