question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SimpleForm's `keepDirtyOnReinitialize` prop should be `false` by default as `final-forms` does.

See original GitHub issue

What you were expecting:

https://github.com/marmelab/react-admin/blob/66e3eeb465b226d23f0096450d9b5e7182cee72c/packages/ra-core/src/form/FormWithRedirect.tsx#L39

Hello, thanks for the great framework. Our team recently spent almost full 2-days to figure out why form.reset() doesn’t work for the dirty field. keepDirtyOnReinitialize property is documented as a false for its default value. However, in RA, it defaults to true going against the document of final-form (see https://final-form.org/docs/final-form/types/Config#keepdirtyonreinitialize). There is no special note about this property in RA’s document, so devs cannot expect this behavior at all.

What happened instead:

The property should have been false as the dependency (final-form) does. Or, at least, we should document this in RA’s document separately.

Steps to reproduce:

Related code:

insert short code snippets here

Other information:

Environment

  • React-admin version: 3.3.1
  • Last version that did not exhibit the issue (if applicable):
  • React version: 16.9.0
  • Browser: N/A
  • Stack trace (in case of a JS error): N/A

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ThieryMichelcommented, Jan 3, 2020

Thanks for the issue.

0reactions
ohtangzacommented, Jan 7, 2020

@fzaninotto Thanks for the detailed response. Your answer was well delivered to my team. If you see this as a design choice, I can agree with the current implementation.

For your information, the example I referred to was from https://final-form.org/docs/react-final-form/examples/simple (with the ‘reset’ examples). The final-form has a decent set of examples for many uses cases. Despite the examples, I also agree that final-form also has issues, for example, removing keys with empty values (perhaps, this is the one you mentioned).

Do you mind if I add some sentences to mitigate this possible confusion? I fully respect your decision, but still want to prevent some possible confusion. I already made a PR (https://github.com/marmelab/react-admin/pull/4260), so you can decide if your team accepts it 😃

Thanks for the great library. This helped our team to save resources significantly!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Final Form Docs – `FormProps`
A predicate to determine whether or not the initialValues prop has changed, i.e. to know if the form needs to be reinitialized with...
Read more >
Set initialValues from props, form state resets on props change
The problem is that when initialValues changes the entire form reinitialises. By default, whatever you pass to initialValues is compared against ...
Read more >
reduxForm(config:Object)
When set to true , the form will reinitialize every time the initialValues prop changes. Defaults to false . If the keepDirtyOnReinitialize option...
Read more >
Final Forms - Bemus Point Central School District
Final Forms. Maple Grove Athletic Department has partnered with FinalForms, an online form and data management service. FinalForms allows you to complete and ......
Read more >
FinalForms: Boost Compliance & Safety
School District compliance starts here! Increase student safety and compliance. Reduce risk, controversy, and liability with FinalForms.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found