Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: Controller disabled prop does not omit built-in validation rules #11267

Closed
1 task done
shushenchik opened this issue Dec 6, 2023 · 1 comment
Closed
1 task done
Labels
status: under investigation aware of this issue and pending for investigation

Comments

@shushenchik
Copy link

shushenchik commented Dec 6, 2023

Version Number

7.48.2

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/competent-butterfly-yfgzsf?file=%2Fsrc%2FApp.js%3A1%2C17

Steps to reproduce

Note: field1 is uncontrolled, field2 is controlled.

  1. Uncheck both isDisabled and isRequired boxes. Submit the form. In the console, you should see the form values object. field1 and field2 are empty strings.
  2. Check only isDisabled box. Submit the form. In the console, you should see the form values object. field1 and field2 are undefined.
  3. Check only isRequired box. Submit the form (leave the text fields empty). You should see "field1 field2" string under the submit button indicating both fields are invalid.
  4. Check both isDisabled and isRequired boxes. Submit the form (leave the text fields empty). You should see "field2" string under the submit button indicating only field2 is invalid.

Expected behaviour

So, the disabled prop of the register method 1) disables the input, 2) leads the input value to be undefined, 3) omits built-in validation rules. But the disabled prop of the Controller component does only 1) and 2), but not 3). It does not skip validation.

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ibrkljacic
Copy link

ibrkljacic commented Dec 6, 2023

I'm facing the same issue. Even though the field has disabled: true property, it still gets validated and sent via params

register from useFormContext behaves as expected when passed disabled flag. Disabled fields are omitted.

useController has an issue...

@bluebill1049 bluebill1049 added the status: under investigation aware of this issue and pending for investigation label Dec 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2024
rafaelcalhau pushed a commit to rafaelcalhau/react-hook-form that referenced this issue May 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: under investigation aware of this issue and pending for investigation
Projects
None yet
Development

No branches or pull requests

3 participants