react-hook-form / input

📋 Wrapper component for controlled inputs
https://react-hook-form.com/api#Controller
158 stars 14 forks source link

Issues with RHFInput and validation #28

Closed piehouserat closed 4 years ago

piehouserat commented 4 years ago

Describe the bug When using a controlled component such as Material UI's radio group along with validation rules, validation errors are not cleared when the component is made valid

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-hook-form-rhfinput-vh5qc
  2. Click on the submit button straight away (notice the validation message on the form)
  3. Select one of the radio button options in order to fix the validation error
  4. Validation error message is still displayed until clicking the submit button again

Codesandbox link https://codesandbox.io/s/react-hook-form-rhfinput-vh5qc

Expected behavior Validation errors should disappear when the component is made valid using the default form mode of 'onChange'

bluebill1049 commented 4 years ago

you can add mode="onChange" to trigger validation onChange.