Skip to content

Commit

Permalink
Merge pull request #16444 from fabioh8010/bugfix/13623
Browse files Browse the repository at this point in the history
[fix] add timeout to Form's onBlur method to prevent focus losing when toggling checkboxes
  • Loading branch information
luacmartins authored Mar 24, 2023
2 parents 7b8f085 + 0150666 commit 2e130e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,13 @@ class Form extends React.Component {
value: this.state.inputValues[inputID],
errorText: this.state.errors[inputID] || fieldErrorMessage,
onBlur: () => {
this.setTouchedInput(inputID);
this.validate(this.state.inputValues);
// We delay the validation in order to prevent Checkbox loss of focus when
// the user are focusing a TextInput and proceeds to toggle a CheckBox in
// web and mobile web platforms.
setTimeout(() => {
this.setTouchedInput(inputID);
this.validate(this.state.inputValues);
}, 200);
},
onInputChange: (value, key) => {
const inputKey = key || inputID;
Expand Down

0 comments on commit 2e130e5

Please sign in to comment.