Skip to content

When Inputs have prop disabled={false}, SaveButton is disabled and dirtyFields is not working as expected. #10613

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

Open
utku656 opened this issue Mar 24, 2025 · 8 comments
Labels

Comments

@utku656
Copy link

utku656 commented Mar 24, 2025

When Input have prop as disabled={false} , it renders component again , reset defaultValues . It is causing a bug , dirtyFields are not working as expected.

What you were expecting:
SaveButton should work as expected.When form input is touched , savebutton should be enabled.

What happened instead:
SaveButton is disabled when there is touched input.

Steps to reproduce:
Add disabled={false} to Inputs in Create page .Then write to this input , you will see that SaveButton is disabled in Create page. You can see it in image that i added. It is also causing a bug in Edit page too.

Image

Other information:

Environment

  • React-admin version:5.6.4
  • Last version that did not exhibit the issue (if applicable):
  • React version:18
  • Browser:Chrome
  • Stack trace (in case of a JS error):
@fzaninotto
Copy link
Member

Did you try using readOnly instead of disabled, as explained in the documentation?

@utku656
Copy link
Author

utku656 commented Mar 24, 2025

Thank you for quick response . I already find a way to fix this issue in my code , i just want to inform you that it is causing a bug.

@fzaninotto
Copy link
Member

How can you "write to a disabled input"? I don't understand the reproduction scenario.

@utku656
Copy link
Author

utku656 commented Mar 24, 2025

I do not write to disabled input . It is happenning if you set disabled={false} to input

@fzaninotto
Copy link
Member

i can't reproduce the error you describe on master. Please attach a sandbox showing the bug, together with a detailed reproduction scenario.

@utku656
Copy link
Author

utku656 commented Mar 24, 2025

https://stackblitz.com/github/marmelab/react-admin/tree/master/examples/simple You can reproduce here , it was also added to post too . Also in the picture i added you can see .You just set disabled={false} to TextInput then try to write to this exactly the same input , you will see that savebutton is not enabled.

@fzaninotto
Copy link
Member

OK, it fails on Stackblitz but works on master... Maybe due to a particular version of react-hook-form. Marking it as a bug for further enquiry.

@djhi
Copy link
Collaborator

djhi commented Mar 28, 2025

It's a known issue with react-hook-form. There are several issues no this in their repository: https://github.com/react-hook-form/react-hook-form/issues?q=is%3Aissue%20disabled%20.

Some are fixed but the fixes have not been released yet. If you can, downgrade to 7.53.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants