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

Initial Values are not showing up in ReferenceArrayInput on second render. #4203

Closed
HemanthEverest opened this issue Dec 23, 2019 · 5 comments · Fixed by #4641
Closed

Initial Values are not showing up in ReferenceArrayInput on second render. #4203

HemanthEverest opened this issue Dec 23, 2019 · 5 comments · Fixed by #4641
Assignees
Labels

Comments

@HemanthEverest
Copy link

HemanthEverest commented Dec 23, 2019

What you were expecting:
Expect the initialValue to be displayed on every render

What happened instead:
initialValue is not showing on second render onwards.

Steps to reproduce:
https://codesandbox.io/s/cool-dust-72uir

  • Go to the comments menu.
  • Click on the create button.
  • Observe that the posts are auto-populated. Do not save or enter any data in the form.
  • Go to comments from the menu again.
  • Click on the create button.
  • Observe that the post are not auto-populated.
  • Click on the post's input. Do not select any value.
  • The initialValue starts to appear.

Environment

  • React-admin version: 3.1.1
  • Last version that did not exhibit the issue (if applicable): 2.*
  • React version: 16.8.6
  • Browser: Chrome 79.0.3945.88
  • Stack trace (in case of a JS error): No Error
@ThieryMichel
Copy link
Contributor

Thanks for the issue.

@fzaninotto
Copy link
Member

Either I don't understand this bug, or it's been fixed in the meantime.

I don't see any initialValue in your CodeSandbox. I don't see any problem when displaying the CommentCreate page for the second time.

Can you rephrase and recheck your CodeSandbox?

@HemanthEverest
Copy link
Author

@fzaninotto The code sandbox was broken since the way we pass defaultValue to ReferenceArrayInput was changed in recent times.

I've fixed the code sandbox. Now you can follow the exact same steps mentioned in the description of the issue to reproduce.

Let me know if you need more info.

Regards,

prasanna214 added a commit to prasanna214/react-admin that referenced this issue Apr 4, 2020
…input.value is undefined.

Closes marmelab#4023[marmelab#4203].

Issue was caused by useField hook of final-form returning defaultValue of field as undefined (when it is not yet available in  state) while enhancing the parent input.

useInput hook of react-admin is considering same enhanced input with value undefined while rendering the children.
prasanna214 added a commit to prasanna214/react-admin that referenced this issue Apr 4, 2020
…input.value is undefined.

Closes marmelab#4023[marmelab#4203].

Issue was caused by useField hook of final-form returning defaultValue of field as undefined (when it is not yet available in  state) while enhancing the parent input.

useInput hook of react-admin is considering same enhanced input with value undefined while rendering the children.
prasanna214 added a commit to prasanna214/react-admin that referenced this issue Apr 4, 2020
…input.value is undefined.

Closes marmelab#4203[marmelab#4203].

Issue was caused by useField hook of final-form returning defaultValue of field as undefined (when it is not yet available in  state) while enhancing the parent input.

useInput hook of react-admin is considering same enhanced input with value undefined while rendering the children.
prasanna214 added a commit to prasanna214/react-admin that referenced this issue Apr 4, 2020
…input.value is undefined.

Closes marmelab#4203
Issue was caused by useField hook of final-form returning defaultValue of field as undefined (when it is not yet available in  state) while enhancing the parent input.

useInput hook of react-admin is considering same enhanced input with value undefined while rendering the children.
@fzaninotto
Copy link
Member

In your example, you're using a <SelectInput> inside a <ReferenceArrayInput>. It does not make sense, you should use a <SelectArrayInput>. But I tested with <SelectArrayInput>, and it does show the same bug.

@fzaninotto
Copy link
Member

The bug comes from the fact that you placed the defaultValue in the SelectInput rather than the ReferenceArrayInput. I understand that you did that because the referenceArrayInput defaultValue was ignored. It is now fixed in #4641.

@djhi djhi closed this as completed in #4641 Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants