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

FormWithRedirect is merging data from the background record #7483

Closed
fzan opened this issue Apr 4, 2022 · 9 comments
Closed

FormWithRedirect is merging data from the background record #7483

fzan opened this issue Apr 4, 2022 · 9 comments
Labels

Comments

@fzan
Copy link
Contributor

fzan commented Apr 4, 2022

What you were expecting:
FormWithRedirect should read only the current form data

What happened instead:
FormWithRedirect read all the background record data then merge them in a single record

Steps to reproduce:
Go here:
https://codesandbox.io/s/react-admin-v3-advanced-recipes-quick-create-preview-forked-kefpy0?file=/src/comments/PostQuickCreateButton.js

on this page, please
0- Open developer tools :-)
a) navigate to /comments/1
b) click on "create"
c) add Title and Teaser
d) please note the console messages

Briefly, the FormWithRedirect component is submitting the two fields (title and teaser) but adding also the fields from comment
(body, created_at, id, post_id, teaser, title)
And that is obviously a problem because the post with id:1 already exist.

You can see that:

  1. react admin is @3.19.10
  2. react final form is at @6.5.9 (same behaviour with 6.5.7)

After 2 days of investigation (...) i noticed that on react@3.19.2 this problem is not happening.
My suspect went to
#6932

specifically related to this

https://github.com/marmelab/react-admin/pull/6932/files#diff-8535e4db04baeef00e2e572f5d575a7202403cdd652c8682082818f0dec7c62e

I'm sorry i cannot provide a fix, because this is beyond my knowledge of the framework :-(

I actually can only suggest a workaround:

  • "clean" the data values during the create phase, removing the background record values.

Environment
in the sandbox

@slax57 slax57 added the bug label Apr 5, 2022
@slax57
Copy link
Contributor

slax57 commented Apr 5, 2022

Reproduced, thanks for submitting this!

@WiXSL
Copy link
Contributor

WiXSL commented Apr 15, 2022

I cannot reproduce this issue with the latest version of react and react-admin v3.
Can you upgrade them?

codeSandbox

@WiXSL WiXSL added needs more info and removed bug labels Apr 15, 2022
@fzan
Copy link
Contributor Author

fzan commented Apr 15, 2022

Hello @WiXSL ,

Just updated the version with 3.19.11
tested on 2 different browsers (just to be really sure the bug is still here)

https://codesandbox.io/s/react-admin-v3-advanced-recipes-quick-create-preview-forked-kefpy0?file=/src/comments/PostQuickCreateButton.js

I can confirm that on 2 different pc, the behaviour is the same
screen

this is also a fork with react admin 3.19.11 and react 17.0.2
https://codesandbox.io/s/react-admin-v3-advanced-recipes-quick-create-preview-forked-dyi66p
screen

@WiXSL
Copy link
Contributor

WiXSL commented Apr 15, 2022

What about trying with react version 17 ?

@fzan
Copy link
Contributor Author

fzan commented Apr 15, 2022

@WiXSL sorry just updated the answer :-)

@fzan
Copy link
Contributor Author

fzan commented Apr 15, 2022

be careful to follow the steps, you are creating the comment, instead you need to update a comment (so a record already exist and is loaded in background) ;-)

to be more clear:

on this page, please
0- Open developer tools :-)
a) navigate to /comments/1 <---- this!
b) click on "create"
c) add Title and Teaser
d) please note the console messages

@fzan
Copy link
Contributor Author

fzan commented Apr 28, 2022

@WiXSL can you please re-add the bug label? it's indeed a bug :-(
thanks

@TCM5
Copy link

TCM5 commented May 23, 2022

I'm also facing this on latest 3.X version (3.19.11). As @fzan said, I also think this bug was introduced on this commit by wrapping the FormContextProvider with the RecordContextProvider

In order to isolate the error, I tested a custom FormContextProvider (just like the version pre-commited) without the wrapper, and it works fine.

After reading conversation about the related commits on version 3.19.3, I noticed that @fzaninotto mentioned a OptionalRecordContextProvider on the next branch, at that time. Why not port this context provider to the 3.X version?

@WiXSL WiXSL added the v3 label May 26, 2022
@fzaninotto
Copy link
Member

With the release of react-admin v5, react-admin v3 has reached its end of life. We won't fix bugs or make any new release on the 3.x branch. We recommend that you switch to a more recent version of react-admin.

So I'm closing this issue as we won't fix it.

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

5 participants