-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[fixed] Abort pending transition if user navigates away #480
Conversation
5ca4f7a
to
df51721
Compare
bbc772b
to
49ba0bc
Compare
I haven't written test cases for this, here's what I intended to do. A -> slowly resolving B
Before fix: when B is ready, will navigate from A to B.
Before fix: when B is ready, will navigate from C to B.
Before fix: when B is ready, will navigate from A to B. A -> slowly resolving and then aborting B
Before fix: when B is ready and aborted, will pop from A to whatever came before A.
Before fix: when B is ready and aborted, will pop from C to A.
Before fix: when B is ready and aborted, will pop yet further! A -> slowly resolving and then redirecting BVery similar to first case. |
49ba0bc
to
14bf154
Compare
I’m afraid I don’t have time to write tests for this today, but I verified those scenarios I describe and they work. We need to see if all react-router examples work correctly, and if they do, I think it’s still better to bring this in without tests because previous racing behavior was broken anyway. |
5508b75
to
888b03a
Compare
888b03a
to
566e8cf
Compare
Previously, navigating (by clicking Back button or a link) while a transition in progress would put router into an inconsistent state. Now, a pending transition will be aborted and ignored by the router if user navigates away while it was pending. Fixes remix-run#479
566e8cf
to
91d4380
Compare
I cleaned it up, would you take a look? I'll be adding tests for now.. |
Now that I'm writing tests, I'll write tests for |
Added tests for basic async transitions (not not the corner cases I'm describing here yet). |
a3c7b93
to
d16d658
Compare
@gaearon This LGTM so far. Thank you for writing tests as well! |
I added more tests. They cover scenarios I mentioned above. |
done(); | ||
}, Async.delay / 2 + 10); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have one more step here that basically just asserts "Foo" is still rendered after the delay and calls done
?
Thanks @gaearon ! This looks great. Hopefully I made some useful comments. |
ea343ec
to
9f7df0b
Compare
[fixed] Abort pending transition if user navigates away
@gaearon, this project is way better because of you, thanks :) |
@rpflorence I'm glad to be of use! |
Previously, navigating (by clicking Back button or a link) while a transition in progress would put router into an inconsistent state.
Now, a pending transition will be aborted by the router if user navigates away while it was pending.
Fixes #479