Skip to content
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

redirect called with undefined after a custom redirect on form save #6259

Closed
ThieryMichel opened this issue May 7, 2021 · 1 comment
Closed

Comments

@ThieryMichel
Copy link
Contributor

What you were expecting:
I use a custom redirect on an edit form: We can edit a teaser from a list of teaser scheduling, and once saved we want to return to the list of scheduling.
For that we use a FormWithRedirect along with a function as a redirect prop.

What happened instead:
On submit, there is a first redirect toward the planned page, then immediately afterward a redirect toward "/" then finally toward the list.

Related code:
Until the 3.14.2 version this worked, but it broke on 3.14.3.
To be precise the bug was introduced by this commit #6145
The redirect created by useRedirect is called with undefined after the first redirect.
Before the change this resulted in a push toward { pathname: undefined } which was ignored.
Since the change in useRedirect this became: {pathname: "/", search: "", hash: ""} causing the bug.

Environment

@ThieryMichel
Copy link
Contributor Author

Found the cause, I had a redirect props that did the redirect itself thus returning undefined.
Which in turn caused the bug when react-admin tried to use its return value.
Fixed it by having it return the url instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant