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: Setting 'disabled' to false in input components crashes the app #10907

Closed
1 task done
marit970 opened this issue Sep 8, 2023 · 11 comments
Closed
1 task done
Labels
question Further information is requested

Comments

@marit970
Copy link

marit970 commented Sep 8, 2023

Version Number

7.46.1

Codesandbox/Expo snack

https://github.com/marit970/react-disabled-bug

Steps to reproduce

  1. Check out the repo
  2. Set the disabled property of the TextInput to false

Expected behaviour

After an update (to v.7.46.1) there is an issue with the 'disabled' property. The app crashes when setting the disabled property in react-admin input components to 'false'. (It works correctly when setting it to 'true' or 'undefined'). This issue appears in v.7.46.0 and v7.46.1 as well. (Also I am using the latest react-admin version 4.13.3).
Bildschirmfoto von 2023-09-08 11-16-55

What browsers are you seeing the problem on?

Firefox, Chrome

Relevant log output

No response

Code of Conduct

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

Interesting to note that what I assume is the field name path in react-admin contains an undefined

rhf-ra-path

@Moshyfawn
Copy link
Member

I've not used react-admin in some time, so I don't remember all the intricacies of the API and how you're supposed to define your resources and their names.

I was able to reproduce the issue with a much lower RHF version; there's a chance your implementation's missing a resource name that's lead to an undefined in the field name path.

Consider checking out the react-admin docs to see of there's a resource definition missing.

@Moshyfawn Moshyfawn added the question Further information is requested label Sep 8, 2023
@marit970
Copy link
Author

@Moshyfawn Thank you, I will check it out

@tgundogdu
Copy link

I'm getting this error too. This error occured from RHF version 7.46.1.

I debug the code and I got the error inside createFormControl.ts

This error occured in strict mode.

image

inside createFormControl.ts
image

I hope this helpful

@marit970
Copy link
Author

@Moshyfawn I noticed that removing strict mode solves the issue. It seems like the getter function itself is undefined on the second render. I guess resources.undefined is not a problem here because it works on the initial render.

@mysuf
Copy link

mysuf commented Sep 11, 2023

I think this is related to what I faced in #10908 when defaultValue is undefined. All clues lead to one specific commit.

@qpointsystems
Copy link

qpointsystems commented Sep 12, 2023

FWIW, removing strict mode did not resolve for me. I also played with setting default values for those fields and that did not provide a work-around.

I'm currently 'hard-coding' until resolved what used to be a more dynamic 'disabled' functionality in my components that was based on state in the parent.

Using syntax e.g. disabled={isDisabled} was, for. me at least, the syntax that triggers issue.

@fzaninotto
Copy link

Hi, I see that this issue was labeled with "question", but to me it is clearly a bug (and a regression). Many users are experiencing this issue, so please consider it as worthy of a rapid fix.

@juliaschiller150
Copy link

Just chiming in to say, I've encountered this same problem with a rather complex form field. This release caused our unit tests to hang, and we can't move forward until it's patched. Thanks everyone for reporting this!

@Defrosted
Copy link

Defrosted commented Sep 21, 2023

Seeing this as well. Setting the disabled attribute to undefined instead of false works when the field is not to be disabled. E.g. disabled={someBoolean ? true : undefined} is a working way of setting it. This was working before, so I reckon this bug was introduced in a recent version.

@cyonder
Copy link

cyonder commented Sep 28, 2023

Came here to open a new issue for it but looks like it's already discovered.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

9 participants