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: Form-level disabled doesn't affect uncontrolled inputs that aren't rendered immediately #12021

Comments

@amitdahan
Copy link

amitdahan commented Jun 16, 2024

Version Number

7.51.5

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/white-glitter-lqhxg3

Steps to reproduce

  1. Visit the repro (https://codesandbox.io/p/sandbox/white-glitter-lqhxg3)
  2. Only the controlled input is disabled

image

Expected behaviour

Both fields are disabled

Code of Conduct

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

From what I can understand, the issue is due to the following useEffect only relying on useForm's disabled field to re-set the disabled field on the currently-registered inputs:

React.useEffect(
() => control._disableForm(props.disabled),
[control, props.disabled],
);

bluebill1049 added a commit that referenced this issue Aug 18, 2024
oskarski pushed a commit to oskarski/react-hook-form that referenced this issue Oct 1, 2024
…-render without trigger by useEffect (react-hook-form#12193)

* 🐞 fix react-hook-form#12021 issue with disable prop not reflect on re-render without trigger useEffect

* fix issue with unit tests
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.