You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tested this with the following configuration:
React Strict Mode enabled
Backend modifying records on update (adding updated_at)
Edit component with redirect={false} and mutationMode="optimistic"
Form with resetOptions={{ keepDirtyValues: true }}
The issue occurs specifically when:
Adding a new item to the ArrayInput
Saving the form
Removing an item
Saving again
The removed item reappears after the save operation, which is unexpected behavior.
Additional observations:
The issue doesn't occur in a standalone react-hook-form implementation
The problem seems to be related to the optimistic update handling in combination with the backend modifications
The issue persists even with different array item structures
Potential workaround:
Temporarily disabling Strict Mode or using mutationMode="pessimistic" seems to prevent the issue, but these aren't ideal solutions.
This appears to be a regression in the optimistic update handling when combined with backend record modifications. The issue might be related to how the form state is being reset or how the optimistic updates are being reconciled with the server response.
Uh oh!
There was an error while loading. Please reload this page.
What you were expecting:
When the following conditions are met:
updated_at
field)<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
The text was updated successfully, but these errors were encountered: