url changes before confirmLeave is satisfied
See original GitHub issueconfirmLeave is a nice feature!
Anyhow, when moving away from that route, url is changed before confirmLeave
is accepted. That should not happen. Apparently confirmLeave
is called after url has already been changed when it should block url change altogether until accepted.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Issues · faceyspacey/redux-first-router - GitHub
Chrome now fires extra popstate event on back, causing confirmLeave prompt to show twice ... url changes before confirmLeave is satisfied question wontfix....
Read more >Activating OnBeforeUnload ONLY when field values have ...
But from what I figure is that the change() event works only after these 3 steps - a field receives focus, a value...
Read more >How to URL changes, Browser refresh, route Navigation in Vue
If that's the case, you need to know "How to prevent browser refresh, URL changes, or route navigation in Vue" in this post....
Read more >Remove site-supplied text for beforeunload and onunload ...
What's needed to resolve this bug: 1. Remove the site-supplied text, since this is a security issue (untrusted text in browser dialogs) 2....
Read more >Return to raid or just confirm leave? : r/EscapefromTarkov
After 10/15 min do I just confirm leave or do I continue to try and ... but they can't even get past loading...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ran into this myself - it happens when you return
false
fromconfirmLeave
. When reaching this line:https://github.com/faceyspacey/rudy-history/blob/ce8bed5d97d8c8c423b09a7c3468e237496aea4b/modules/createTransitionManager.js#L39-L40
The redux action is skipped after
callback(false)
happens (callback(true)
seems to be the expected behaviour to allow the transition to occur normally)You can work around the issue by returning a falsy value other than
false
(e.g.undefined
) fromconfirmLeave
, although I’d say its definitely a bug. Not sure what the purpose of that line is though.confirmLeave
needs to be a synchronous function - is that the case here?Here is where the handler is created to check confirmation if you enter a route where you have configured
confirmLeave
(in_afterRouteChange
):https://github.com/faceyspacey/redux-first-router/blob/0a3ff66832849a634531802ca7e1800cb91ad789/src/connectRoutes.js#L420-L429
Here is where it blocks the navigation in
_beforeRouteChange
if the handler has been set up for the current route (before the route change):https://github.com/faceyspacey/redux-first-router/blob/0a3ff66832849a634531802ca7e1800cb91ad789/src/connectRoutes.js#L321-L330
If
_beforeRouteChange
returns true, then the middleware should skip dispatching the action and changing the URL:https://github.com/faceyspacey/redux-first-router/blob/0a3ff66832849a634531802ca7e1800cb91ad789/src/connectRoutes.js#L298-L304
Perhaps you could work out which part is going wrong?