-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
after delete & redirect from Edit page, react-admin still does a refresh on edit page calling getOne
on the deleted object
#5541
Comments
getOne
on the deleted objectgetOne
on the deleted object
Thanks for reporting this. Please provide a sample application showing the issue by forking the following CodeSandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple). |
It will be difficult to provide that without copying a lot of our code since the issue doesn't show in the simple example given. The issue I believe comes in because we have a more complicated app so it may take longer for the redirected list page to paint. It's a custom list view. Fundamentally I don't think you can assume that after a
I'll be experimenting with a custom |
Maybe a dumb question but do you return the data of the specific item that you deleted?
|
(yes we return the deleted record from the I have fixed the issue by doing this - I believe it confirms this is a race condition between redirection and refresh:
Case 1 : with copy of existing code
A CRUD_GET_ONE action is sent prior to CRUD_GET_LIST i.e. still on the Edit page on the deleted element. This is the issue reported. Case 2: with modified code (delayed refresh)
No CRUD_GET_ONE action is sent and the forced refresh now happens on the list page after redirection. (note: I modified the data provider to always return a valid response from getOne, i.e. returns The fix is ugly with the setTimeout but I believe it proves this is a genuine bug that may only show up in some cases (and since ra now uses react-router v5 I wouldn't be surprised there is different behavior due to that) |
Interesting feedback, thanks a lot for the details. Now we need to understand when the bug actually occurs, as we haven't been able to reproduce it so far. Could you try and reduce the conditions to reproduce the bug? |
We actually have a deadline for a product introduction in the next few weeks that uses ra as an admin UI, so I'm a bit strapped for time right now.
All this can cause that it takes more time than typical (but definitely less than 500ms since the issue goes away with a delay of 500ms on the refresh) to paint the list view. So I would think mocking a list view in which you on purpose delay completing the render should have this issue show up. Also I first tried to use the approach described here with the listener (https://stackoverflow.com/questions/45373742/detect-route-change-with-react-router) and call Fundamentally it needs some looking into react-router and history API to determine how to detect when it actually completes page load after |
#6063 ? |
Did you fix this bug, because I have the same bug on my project? |
I have no answer on this at this time. We are still using the delayed refresh workaround in a customized DeleteButton as explained in my earlier post and that works for us. #5815 seems different to me as we are not using a forced redirect. |
I'm still experiencing this issue: once the resource is deleted, React Admin redirects me to the |
Same issue here. An item gets deleted then a failure occurs when a @WiXSL I don't believe the issue is related. I have upgraded to the most recent version and am running into the same problem. |
A codesandbox would help us to debug this. |
Same issue here! It also occurs List view. |
Not sure if it's related: Added extra CASE for DELETE
Which solved it for me. |
I am having the exact same issue, after deleting the record, even if the delete occurred successfully, I still see a |
Inside I made a custom element without using
|
Huge thanks to @TannicArturo98 who seemed to have the most elegant solution of the ones listed here. This worked out great for us when we ran into the same React Admin bug as the others in this thread. Too bad we can't get an official fix or review from the Marmelab team since nobody knows precisely how to create a repro that manifests the issue. |
I ran the same problem here, and compared my API response with json-api response(that does not trigger this bug) and discovered that if the server return the item object after delete call, react-admin will try to fetch the item.(??) Solution: tweak the dataProvider or the API itself to return an empity object |
Hearing what @pacau999 said, I did this: |
This issue has been opened for a very long time without anyone providing a repro with CodeSandbox. We can't work on a bugfix if we can't replicate the bug. So I'm closing this issue. If you have this bug, please open a new issue and attach a link to a CodeSandbox demonstrating it, following the issue template. |
Edit page,
undoable
is set to false.As soon as we press confirm on Delete, react-admin issues a
delete
and then agetOne
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
andlist
view set for redirection and redirection happens, but it seems too late (after the page refresh).Similarly with
undoable
set to true, we see aCRUD_GET_ONE
action being pushed onto theoptimisticCalls
array which will issue agetOne
after the server sends the response fromdelete
.There should be a redirect to list page PRIOR to the refresh as in
useDeleteWithConfirmController.ts
redirect
is called beforerefresh
(we do not use our ownonSuccess
handler). We would expect agetList
to be called to refresh list view, notgetOne
.It seems the redirection comes too late. See screenshots:
getOne
, browser still shows Edit page.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
The text was updated successfully, but these errors were encountered: