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
fix(#11239): Set fields disabled state based on form and field disabl… #11241
Conversation
…nd field disabled prop
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for the PR! could you please include a unit test for this usecase well.
src/logic/createFormControl.ts
Outdated
(ref, name) => { | ||
const currentField = get(_fields, name); | ||
if (currentField) { | ||
ref.disabled = currentField._f.disabled || disabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably need to check currentField._f.disabled
is defined as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a hard time figuring out if there is a standard way you like to check these, hope this is sufficient :)
Added a test as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
… and field disabled (react-hook-form#11241) * fix(react-hook-form#11239): Set fields disabled state based on form and field disabled prop * fix(react-hook-form#11239): If-check and unit test * Update createFormControl.ts --------- Co-authored-by: Thomas De Bock <thomas.de.bock@persgroep.net> Co-authored-by: Beier (Bill) <bluebill1049@hotmail.com>
Quickfix on #11239
Needs some love by somebody who knows the internals better than I do.