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

Form refresh issue after edit #9327

Open
qcalmel opened this issue Oct 3, 2023 · 12 comments
Open

Form refresh issue after edit #9327

qcalmel opened this issue Oct 3, 2023 · 12 comments
Labels

Comments

@qcalmel
Copy link

qcalmel commented Oct 3, 2023

Hello, i've an issue when I edit a record :
If I delete an existing field value, save form and just after, modify another field and save form again,
my previous field to which I deleted the value, returns to its previous value.
When form is refreshed after save, If I check the React Query dev tool, the data are however good
It's occurs only when field value was previously set to null
Little precision : I use Airtable as database, and records fields that are null are not retrieved from the record data

Steps to reproduce:

Environment

  • React-admin version: 4.14.4
  • Last version that did not exhibit the issue : 3.11.3 (yeah big jump 😅)
  • React version: 17.0.0
  • Browser: Chrome, Safari, Firefox
@djhi
Copy link
Contributor

djhi commented Oct 3, 2023

I tried to reproduce your issue in the provided stackblitz without success. Can you double check your instructions?

@qcalmel
Copy link
Author

qcalmel commented Oct 3, 2023

hi, a video is better than a long speech :
https://jam.dev/c/e2986df8-780c-4152-969f-9d60132f1265
the bug occurs also if you use refresh button :
https://jam.dev/c/480ecc35-a796-4f21-ba8e-2995d3efc2dc

@djhi
Copy link
Contributor

djhi commented Oct 3, 2023

Finally reproduced it. Thanks. Tracked it to the fact that react-hook-form does not accept null nor undefined values (https://react-hook-form.com/docs/usecontroller). We should detect it however and sets the defaultValue to an empty string when we receive null.

In the mean time, you'll have to update your dataProvider to return an empty string for fields that are null and set them back to null in the update

@djhi djhi added bug and removed needs more info labels Oct 3, 2023
@shavidze
Copy link

shavidze commented Oct 4, 2023

Data is lost on page refresh as well, for example :

  • Input test in Name field
  • Save
  • Refresh the page

@shavidze
Copy link

shavidze commented Oct 4, 2023

About the above-mentioned issue:

The codebase is quite complex and large, what I guess is that save function in useEditController does not work as expected.

@qcalmel
Copy link
Author

qcalmel commented Oct 4, 2023

Finally reproduced it. Thanks. Tracked it to the fact that react-hook-form does not accept null nor undefined values (https://react-hook-form.com/docs/usecontroller). We should detect it however and sets the defaultValue to an empty string when we receive null.

In the mean time, you'll have to update your dataProvider to return an empty string for fields that are null and set them back to null in the update

Thanks for temporary fix solution, i almost found this solution but I returned null value instead of empty string 😅

@gitstart
Copy link
Contributor

@djhi we would like to work on this Issue.

@fzaninotto
Copy link
Member

@gitstart you don't need our permission: you can open a PR mentioning this issue.

@shavidze
Copy link

@fzaninotto I tried to work on it but the project is very complex and with high level abstractions. My brain was burnt 😃

@slax57
Copy link
Contributor

slax57 commented Oct 16, 2023

@gitstart there are already 3 open PRs for your account (https://github.com/marmelab/react-admin/pulls/gitstart), for all of which changes are requested but not made.
May I suggest your team starts by focusing on getting those PRs merged before attempting to open a new one?

@gitstart
Copy link
Contributor

@slax57 Apologies for not being able to address the requests.
For this PR we addressed the query after that no reviews were given.
In this PR we will try to rebase, if it doesn't work out will close this PR and push a new one against the next branch.
Last PR will be reassigned and a solution will be pushed asap.
Thank you for your cooperation.

@slax57
Copy link
Contributor

slax57 commented Oct 18, 2023

@gitstart I reviewed the 1st PR and requested some changes and fixes. Thanks.

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

No branches or pull requests

6 participants