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

warnWhenUnsavedChanges not working when navigating to show from edit #8338

Closed
mathieulordon-nimaling opened this issue Oct 31, 2022 · 3 comments · Fixed by #8512
Closed

warnWhenUnsavedChanges not working when navigating to show from edit #8338

mathieulordon-nimaling opened this issue Oct 31, 2022 · 3 comments · Fixed by #8512
Labels

Comments

@mathieulordon-nimaling
Copy link

mathieulordon-nimaling commented Oct 31, 2022

What you were expecting:

In the simple example https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple, when I navigate to a comment, edit the author name for example, and click the show button, I expect to have an alert saying my changes weren't saved.

What happened instead:

No alert is displayed and my changes are lost.
When I click on an other resource in the menu, the alert is displayed.

@WiXSL
Copy link
Contributor

WiXSL commented Oct 31, 2022

Thanks.
I believe is the same problem as described with the CreateButton below the ShowButton you are reporting in that code example.
It should get fixed like this for now:

{/* FIXME: added with resource prop because react-router HashHistory cannot block navigation induced by address bar changes */}
<ShowButton resource="posts" record={record} />
{/* FIXME: added with resource prop because react-router HashHistory cannot block navigation induced by address bar changes */}
<CreateButton resource="posts" label="Create post" />

Would you like to create a Pull Request with this fix?

@mathieulordon-nimaling
Copy link
Author

https://codesandbox.io/s/wizardly-rain-7p6pxp?file=/src/comments/CommentEdit.tsx:2650-2665

That's not really a fix even for CreateButton.

CreateButton should redirect to the creation of a comment.
ShowButton should redirect to the show page of the comment.

But…
CreateButton redirects to the creation of a post.
And with the same change, ShowButton redirects to the post with the id equals to the id of the comment (comment 1 => post 1, comment 2 => post 2, etc.) Not even the post the comment is linked to.

@WiXSL
Copy link
Contributor

WiXSL commented Nov 1, 2022

...CreateButton should redirect to the creation of a comment.... for what I see, this was done on propose to make cypress tests pass because of the FIXME comment.

ShowButton should redirect to the show page of the comment., you are right, my mistake.

Your original concern is the main issue here, I will look into it.

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

Successfully merging a pull request may close this issue.

2 participants