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

fix(#11239): Set fields disabled state based on form and field disabl… #11241

Merged
merged 3 commits into from Nov 29, 2023

Conversation

thomasdbock
Copy link
Contributor

Quickfix on #11239
Needs some love by somebody who knows the internals better than I do.

Copy link

codesandbox bot commented Nov 28, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Member

@bluebill1049 bluebill1049 left a 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.

(ref, name) => {
const currentField = get(_fields, name);
if (currentField) {
ref.disabled = currentField._f.disabled || disabled;
Copy link
Member

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.

Copy link
Contributor Author

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.

bluebill1049
bluebill1049 previously approved these changes Nov 29, 2023
Copy link
Member

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@bluebill1049 bluebill1049 merged commit d949850 into react-hook-form:master Nov 29, 2023
7 checks passed
rafaelcalhau pushed a commit to rafaelcalhau/react-hook-form that referenced this pull request May 5, 2024
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants