What you were expecting:
SelectInput works as expected and doesn't cause Create form to reset its values when switching between form tabs.
What happened instead:
SelectInput with defaultValue set causes Create form reset its values when switching between form tabs.
Steps to reproduce:
SelectInput with defaultValue setRelated code:
<Create {...props}>
<TabbedForm>
<FormTab label="Tab 1">
<TextInput source="title" />
<SelectInput
source="type"
choices={[
{ id: "type1", name: "Type 1" },
{ id: "type2", name: "Type 2" }
]}
defaultValue={"type1"}
/>
</FormTab>
<FormTab label="Tab 2">
<TextInput source="title" />
</FormTab>
<FormTab label="Tab 3">
<SelectInput
source="category"
choices={[
{ id: "cat1", name: "Category 1" },
{ id: "cat2", name: "Category 2" }
]}
defaultValue={"cat1"}
/>
</FormTab>
</TabbedForm>
</Create>
or check this CodeSandbox.
The following happens in Product Create form:
CodeSandbox
https://codesandbox.io/s/6n0xlnjzkn
Other information:
I noticed this behaviour in earlier versions (I think it's there from at least 2.0.2).
Environment
Yes, I got the same problem
Just checked. I fixed this too with #1997
Will be available in next minor release 2.1.2
When 2.1.2 will release?
Btw, thanks @zavadpe for reporting and setting up a codesandbox. It really helps :+1:
@fzaninotto I noticed that fix for this has been reverted in 2.1.4 (seemed to be mostly fixed in 2.1.2 and 2.1.3 although I saw it happen at particular places in my codebase). Any plans to fix it in 2.1.5? This issue should be probably reopened then.. cc: @djhi
@zavadpe I can't reproduce it on 2.1.4. Can you setup a codesandbox showing the issue ?
Nevermind, I just reproduced it
Fixed by #2082
Most helpful comment
Just checked. I fixed this too with #1997
Will be available in next minor release
2.1.2