Skip to content

Commit

Permalink
Merge pull request #13810 from Expensify/marco-fixLangErrorMessages
Browse files Browse the repository at this point in the history
Fix error messages when language changes
  • Loading branch information
marcochavezf authored Jan 10, 2023
2 parents a26d600 + a4f93a9 commit c493729
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ class Form extends React.Component {
this.submit = this.submit.bind(this);
}

/**
* @param {String} inputID - The inputID of the input being touched
*/
setTouchedInput(inputID) {
this.touchedInputs[inputID] = true;
componentDidUpdate(prevProps) {
if (prevProps.preferredLocale === this.props.preferredLocale) {
return;
}

// Update the error messages if the language changes
this.validate(this.state.inputValues);
}

getErrorMessage() {
Expand All @@ -110,6 +112,13 @@ class Form extends React.Component {
return _.first(_.keys(hasStateErrors ? this.state.erorrs : this.props.formState.errorFields));
}

/**
* @param {String} inputID - The inputID of the input being touched
*/
setTouchedInput(inputID) {
this.touchedInputs[inputID] = true;
}

submit() {
// Return early if the form is already submitting to avoid duplicate submission
if (this.props.formState.isLoading) {
Expand Down

0 comments on commit c493729

Please sign in to comment.