What you were expecting:
When the following conditions are met:
React Strict Mode is enabled
Records are modified by the backend each time they are updated (e.g. to add an updated_at field)
<Edit> has redirect={false}
<Edit> has mutationMode="optimistic"
<Form> has resetOptions={{ keepDirtyValues: true }}
I should be able to remove items from an <ArrayInput>.
What happened instead:
Instead, the removed item keeps reappearing after I click Save.
Screencast.2024-12-18.14.55.42.mp4
Steps to reproduce:
Open https://stackblitz.com/edit/github-ds11wg7c?file=src%2Fposts%2FPostEdit.tsx
Click on Post with id 13
Add a new item
Save
Remove item
Save
Notice the removed item came back!
Related code:
https://stackblitz.com/edit/github-ds11wg7c?file=src%2Fposts%2FPostEdit.tsx
Other information:
I also tried to reproduce this issue in a react-hook-form only sandbox, but it does not seem to have the issue.
https://codesandbox.io/p/sandbox/sweet-rhodes-nn7nl8?workspaceId=ws_GvfcTzCi2aJ7bCaQr5bmfV
Environment
React-admin version: 5.4.2
Last version that did not exhibit the issue (if applicable):
React version: 18
Browser: Chrome
Stack trace (in case of a JS error):
What you were expecting:
When the following conditions are met:
updated_atfield)<Edit>hasredirect={false}<Edit>hasmutationMode="optimistic"<Form>hasresetOptions={{ keepDirtyValues: true }}I should be able to remove items from an
<ArrayInput>.What happened instead:
Instead, the removed item keeps reappearing after I click Save.
Screencast.2024-12-18.14.55.42.mp4
Steps to reproduce:
Related code:
https://stackblitz.com/edit/github-ds11wg7c?file=src%2Fposts%2FPostEdit.tsx
Other information:
I also tried to reproduce this issue in a react-hook-form only sandbox, but it does not seem to have the issue.
https://codesandbox.io/p/sandbox/sweet-rhodes-nn7nl8?workspaceId=ws_GvfcTzCi2aJ7bCaQr5bmfV
Environment