Skip to content

Commit

Permalink
Submit request to backend only if userInput not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Wentzel committed Dec 16, 2024
1 parent 0318363 commit 217eca6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions assets/js/Containers/FrevaGPT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,18 @@ class FrevaGPT extends React.Component {
}

async handleKeyDown(e) {
if (e.key === "Enter") {
if (e.key === "Enter" && !isEmpty(e.target.value)) {
this.handleSubmit(e.target.value);
}
}

async submitUserInput() {
const userInput = this.state.userInput;
await this.handleSubmit(userInput);

if (!isEmpty(userInput)) {
await this.handleSubmit(userInput);
}

this.setState({ userInput: "" });
}

Expand Down

0 comments on commit 217eca6

Please sign in to comment.