-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Introduce useBulkDeleteController
#10923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
packages/ra-core/src/controller/button/useBulkDeleteController.ts
Outdated
Show resolved
Hide resolved
const handleConfirm = e => { | ||
setOpen(false); | ||
handleDelete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I missed that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
packages/ra-ui-materialui/src/button/BulkDeleteWithUndoButton.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #10923 (comment)
Problem
Just like the
<DeleteButton>
we want a controller hook that ease the implementation of<BulkDeleteButton>
in custom UIs.Solution
Introduce
useBulkDeleteController
How To Test
The
<BulkDeleteWithConfirmButton>
and<BulkDeleteWithUndoButton>
should work as before.Additional Checks
master
for a bugfix or a documentation fix, ornext
for 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.