-
Notifications
You must be signed in to change notification settings - Fork 159
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
Fix URL Update Method for QP-replacement during Transition #303
base: master
Are you sure you want to change the base?
Conversation
Part of what would be really helpful in resolving this would be to clarify the expected sequence of events. I would assume that when a new QP-only transition occurs during another transition, the active transition is aborted in favor of the new transition, like normal. However, that's specifically not what happens. Instead, the new query params are assigned to the active transition and both are allowed to complete. Does it make sense that that's the behavior? I was able to get the code to do what I would have expected to happen, but other tests started to fail when I made that change. This really has me wondering what the correct behavior is supposed to be in a case like this. For example, this test ensures that when you transition to route I would think that it actually should be call |
This makes a QP-only transition that updates an active transition actually replace the active transition, rather than them both happening. We also keep track of whether the interrupted transition was intending to update the URL, because a replacement that interrupts an update should still update the URL.
I decided to go ahead and push the code I have written toward fixing this error so that it can be looked at. The change here is essentially that
If it seems like the existing tests are ensuring the incorrect behavior, I'm happy to go and update them to match the new behavior. For now, I want to leave them alone as a discussion point. |
Can you push an additional commit updating those tests just so its easier to review and try to grok the impact to apps? |
let newTransition = new InternalTransition( | ||
this, | ||
undefined, | ||
undefined, | ||
undefined, | ||
this.activeTransition | ||
); |
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.
I'm attempting to fix a semi-related bug (emberjs/ember.js#18577) in #307.
- let newTransition = new InternalTransition(this, undefined, undefined);
+ let newTransition = new InternalTransition(this, undefined, newState);
@rwjblue I just tried to dig into this. I've rebased against master (more exactly against https://github.com/sly7-7/router.js/commits/fix-ember-19266), and I think those remaining failing tests |
@alexlafroscia Could you look at this "interesting" example please ? emberjs/ember.js#11563 (comment) I'm navigating through router issues, and for now this PR seems to fix some of them, but this #11563 is still failing. (or maybe it allows an other underlying issue to surface) |
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.
Having just reviewed the changes here again, I think the code here is good overall (and the right direction). We need to dig into those test failures to decide if they are legit or just mistaken assertions.
@rwjblue Thank you for the review. I were investigating emberjs/ember.js#11563 and realize that a test I just wrote in ember.js code looks the same as in emberjs/ember.js#19092, causes the same error I can eventually push this forward if @alexlafroscia doesn't have the time. But as I said, I don't know what's the expected behavior, and also don't have a good knowledge about the differences between replaceUrl/updateUrl and what that means for the browser and the end user (Yes, I don't have the basis on web dev). I guess this also depends on the locationType used in the app. |
Hey everyone, sorry I've been MIA as this conversation picks up again. It's been a while since I was knee-deep in this problem and I've sort of lost context on what I was doing. @sly7-7 if you're working through this now, feel free to pick it up where I put it down. If you want to take some time to chat through the decisions that need to be made around the tests or pair on something, I'm happy to set up some time for that this week! |
@alexlafroscia Thank you for your answer. I'm currently navigating trough a lot (at least for me it's a lot) of issues in the router. I'm on other ones right now + trying to understand how routing works. But definitely, I think this PR is relevant, and no doubt I will come back later on it. |
@sly7-7 status? |
As part of investigating what parts of the failing tests in emberjs/ember.js#19092 might be part of
router.js
-- as a means of getting to a solution for emberjs/ember.js#18416 -- I wrote up these tests to try to isolate the behavior that should be happening here.Essentially, it seems to me that if you perform a new "replacement" transition during an active "update" transition which only changes the query params, the browser should only push one item into the History stack; a URL update to the URL with the query params.
However, that's not what actually happens; in reality, a
replaceURL
happens from the "replacement" transition and then theupdateURL
happens. This gets the browser's Back button all kinds of confused.