react-hook-form: Validation gets triggered on blur even the mode was set to 'onChange'
Describe the bug
Hi, I just found a bug with the onChange mode. Validation gets triggered on blur even the mode was set to onChange
To Reproduce Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/react-hook-form-controller-1wurt
- Click on Uncontrolled input textbox (dont type anything)
- Remove the focus
- Error is shown
Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-controller-1wurt
Expected behavior
Error should not be shown if the mode is onChange because the user doesn’t perform any input changes. This should only happen if the mode is onBlur
Desktop (please complete the following information):
- OS: Mac OS Mojave
- Browser: chrome
- Version: 80.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (8 by maintainers)
Commits related to this issue
- fix #1213 validation rule inconsistency — committed to react-hook-form/react-hook-form by bluebill1049 4 years ago
5.1.2-beta.1here you go.no, not really. i will have to release a beta version for this.
I will re-open this issue so i remind myself to publish a beta version.
onChangeshould only trigger validationonChange, this is a bug which i will fix for native input.Actually, I think this behaviour is expected. If the mode was set to
onChange, it should also trigger theonBlur.If this is the case, it’s the other way around. The controlled component doesn’t trigger the validation if the the input has been focused and blurred without user input.