refine
refine copied to clipboard
[BUG] undoable mutation is called many times
Describe the bug
When updating multiple records at the same time whose mutationMode is undoable, the doMutation() method is called multiple times leading to duplicate API calls for the dataProvider.
To Reproduce Steps to reproduce the behavior:
- Go to a list page where multiple records are shown. useUpdate or useUpdateMany works best for this. Ensure the mutation function for the records defines
mutationMode: "undoable" - Edit one of the records.
- While the toast message from step 2 is still shown, update different record.
- While the toast message from step 2 is still shown, update the same record from step 2 again
Expected behavior Viewing the network calls made from the browser, you will see that many more API calls to the dataProvider endpoint were executed. You would expect that with 3 updates made, only 3 API calls would have been performed.
Screenshots
I've modified the refine-advanced-table-example with the following changes in order to better represent this issue:
- The "Delete selected items" button is not disabled while waiting for the success of the undoable mutation.
- The
useDeleteManymutation has been changed touseUpdateManyso that records are not removed and can be modified multiple times.
I believe these changes provide a more simplistic use case which serves to demonstrate the issue. Disabling the "Delete selected items" button is definitely a work around for this issue, but a requirement to disable the user from disabling any edit functionality is not clearly mentioned in documentation.
https://user-images.githubusercontent.com/8311573/191482087-ef33607f-4ea5-4d25-83c6-4bbdec76c850.mov
Desktop (please complete the following information):
- OS: MacOS
- Browser chrome
- Version 105.0.5195.125
- Used dataProvider [e.g. custom, Strapi, Airtable]
Additional information A possible fix for this is shown here: https://github.com/pankod/refine/compare/next...collinpreston:refine:remove-notificationItem-at-time-zero
Hey @collinpreston , Thank you for contacting us! We had the idea to refactor the undoable queue. with this issue, we can make it happen! 🚀
Hey @collinpreston, We've created #2559 . We will probably release it tomorrow 💥 Thank you for your understanding and patience
Hey @collinpreston ,
We've released @pankod/[email protected]. Could you approve this fix?