question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

url changes before confirmLeave is satisfied

See original GitHub issue

confirmLeave 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:open
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hedgepigdanielcommented, Nov 6, 2018

I ran into this myself - it happens when you return false from confirmLeave. 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) from confirmLeave, although I’d say its definitely a bug. Not sure what the purpose of that line is though.

1reaction
hedgepigdanielcommented, Nov 3, 2018

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found