-
Notifications
You must be signed in to change notification settings - Fork 36
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
The URL does not reflect the current page after refreshing on a form and then cancelling the navigation warning. #37
Comments
thanks for the thoroughly written issue, @shepswitcher . unfortunately i am busy and cannot look into it right now. maybe this weekend? |
No worries! It's my first issue filed on GitHub actually That's not a problem. This weekend will be good thank you |
@shepswitcher as you may have noticed, i did not get around to it last weekend, and i doubt i will this week |
Yep that is totally fine mate! No rush here, whenever you're free is cool |
react-router's history.block() is not being invoked, so fixing this would require a solution similar to what NavigationPrompt is doing with I looked into using window.addEventListener('popstate'), but the event was never triggered (Chrome v69). Any ideas on how to get a handle on the event? |
Thanks for looking into this! |
My bad, I had a filter that caused me to not see the logs history.block() was making. This is quite an edge case! It seems that react-router is ignoring the request to block navigation because we are navigating to a context not handled by this "session" of react-router (I haven't looked at their code, but this seems to be the case). Ie, it seems that react-router is treating this identically to navigating to a separate site. Meanwhile, the browser sees this as navigating to the same site, so 'beforeunload' is not getting triggered. There might be a solution with window.addEventListener('popstate'). I don't think I'll get around to looking into it for at least a week. If you can help, I'd appreciate it! |
All good. Makes sense now! |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
The URL does not reflect the current page after refreshing on a form and then cancelling the navigation warning.
If the current behavior is a bug, please provide the steps to reproduce.
Tested on 3 browsers (Firefox/IE11/Chrome).
What is the expected behavior?
After refreshing, the URL should not change when being prompted before navigating away. Instead, it should only change the URL in the address bar when the onConfirm is called and the page needs to redirect.
Please post the output of
npm list react react-router react-router-dom react-router-navigation-prompt
(with redactions if needed).├── react-router@4.3.1
├─┬ react-router-dom@4.3.1
│ └── react-router@4.3.1 deduped
└── react-router-navigation-prompt@1.6.5
The text was updated successfully, but these errors were encountered: