Repository navigation
Introduce useBulkDeleteController - #10923
Conversation
| const handleConfirm = e => { | ||
| setOpen(false); | ||
| handleDelete(); |
There was a problem hiding this comment.
This is not equivalent to the behavior we had before: now you will close the Dialog immediately, even if an error occurred
There was a problem hiding this comment.
We did close the dialog when an error occured:
https://github.com/marmelab/react-admin/pull/10923/files#diff-178b61dec45337796901d9f0e764b388977fa66713f2d26fb6af6624aa1391d3L93
There was a problem hiding this comment.
Actually, thinking about this again, this is still not equivalent. In pessimistic mode, the dialog would be closed after the end of the mutation, whereas now it is closed immediately. This means the user would be redirected to the list too soon, as the refresh will only happen later, when the mutation succeeds.
So we definitely need an onSettled here I believe.
Problem
Just like the
<DeleteButton>we want a controller hook that ease the implementation of<BulkDeleteButton>in custom UIs.Solution
Introduce
useBulkDeleteControllerHow To Test
The
<BulkDeleteWithConfirmButton>and<BulkDeleteWithUndoButton>should work as before.Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a feature- [ ] The PR includes unit tests (if not possible, describe why)we decided to not invest more in tests as we already have some for the existing buttons.- [ ] The PR includes one or several stories (if not possible, describe why)Same- [ ] The documentation is up to dateSameAlso, please make sure to read the contributing guidelines.