after delete & redirect from Edit page, react-admin still does a refresh on edit page calling `getOne` on the deleted object
See original GitHub issueEdit page, undoable
is set to false.
As soon as we press confirm on Delete, react-admin issues a delete
and then a getOne
on the deleted record.
This causes a rejected promise from the data provider (since the object is not found) which shows an ‘element not found’ popup in react-admin UI. We have a basePath
and list
view set for redirection and redirection happens, but it seems too late (after the page refresh).
Similarly with undoable
set to true, we see a CRUD_GET_ONE
action being pushed onto the optimisticCalls
array which will issue a getOne
after the server sends the response from delete
.
There should be a redirect to list page PRIOR to the refresh as in useDeleteWithConfirmController.ts
redirect
is called before refresh
(we do not use our own onSuccess
handler). We would expect a getList
to be called to refresh list view, not getOne
.
const [deleteOne, { loading }] = useDelete(resource, null, null, {
action: CRUD_DELETE,
onSuccess: response => {
setOpen(false);
if (onSuccess === undefined) {
notify('ra.notification.deleted', 'info', { smart_count: 1 });
redirect(redirectTo, basePath);
refresh();
} else {
onSuccess(response);
}
},
It seems the redirection comes too late. See screenshots:
- press the confirm button in Dialog. With breakpoint set on refresh, screen still shows the Edit page while the URL bar already shows the path for the list view.
- breakpoint in data provider’s
getOne
, browser still shows Edit page. - then react-admin shows list view (and it will pop-up the ‘element not found’ notification)
Is there a race condition so redirect does not complete prior to the refresh?
How can we fix this?
React-admin v.3.10.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:21 (7 by maintainers)
Top GitHub Comments
I am having the exact same issue, after deleting the record, even if the delete occurred successfully, I still see a
getOne
request which yields an “Element not found” snackbar.I’m still experiencing this issue: once the resource is deleted, React Admin redirects me to the
List
view and fetches the deleted resource withGET_ONE
.