-
Notifications
You must be signed in to change notification settings - Fork 68
Portals and Session history #19
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
Comments
What about on deactivation in the case where the an activated portal adopts its predecessor? That is:
What does the history stack look like at that point? Is it [A, B, A]? Is there some way to have it be [A] as if there were a back navigation? |
Even more complicated:
|
In this case:
If the session history was initially empty, I would expect it to first have [A], as the user navigated to A, then when B is activated, it would have [A, B], then when A is activated we would have [A,B,A]. If the user pressed the back button in the second step instead, then the history would have [A,B] where A is the current entry (i.e. the forward button would be active). This is the same behavior as a navigation, and I think the most intuitive to the user. On the second example:
Then the session history would have [A,B,B#state,A]. B could also use replaceState if it would want to avoid creating a new entry. |
So in this case:
Will this back navigation behave differently depending on whether B adopts A or not? In the case of:
Will A receive the
Does that mean it's impossible to make it smooth or just that it may not be smooth if A isn't adopted and thus able to handle the navigation smoothly? |
This is something we considered, but we didn't find a way for the user agent to know the intent of the page when navigating back, so it would be hard to define something other than navigating. Achieving your desired behavior (smooth transition back) would still be possible though, the page would have to:
|
Just want to make sure I understand this:
You're saying there will be an extra state on the stack? Like [A, B {base:true}, B {base:false} ] So when the user navigates back, B can check |
Yes, that's right. We have also considered having an optional parameter, or a different method to activate the portal that would replace the entry in the session history, similar to |
Yeah, I agree that it doesn't seem like supporting replace would fix back navigation case. I could still image replace being useful. For the cases from Key Scenarios I think it would probably be preferable for "Carousel of articles from different websites" and "Publication with an infinite list of articles" to use replace rather than push. I think push could work for these, but I also think it could be potentially surprising to develop a large history stack while scrolling or swiping through documents. |
History is a very loaded topic. Do you think any history API would be available to portal in a non-activated mode? This area might deserve a separate issue. With activation/deactivation: I think some control w.r.t. push/replace should be available to both A and B. However, the E.g. consider this:
|
@jeremyroman raised some concerns with the complexity of this "stack of stacks" idea that @dvoytenko We discussed some ideas to try and allow JS to fake this, such as by providing some sort of identifier for a history state so that history can reliably pop to a specific state. This isn't perfect since it would still require popping states. That is instead of [A0, A1, A2, [B0, B1]] -> [A0, A1, A2] you would have to do: [A0, A1, A2, B0, B1] -> [A0, A1, A2, B0] -> [A0, A1, A2]. If B was then reactivated, it would be in its base state, B0, instead of B1. I like Dima's suggestion that the history stack for a document should be preserved in a deactivated portal. |
@jeremyroman @ericfs One thing to note: Firefox is actually doing some stack of stack management of iframes. For instance, an iframe can push into the global history as one would expect. But when an iframe is removed, all history items associated with it are removed from global history stack. Comparing to that, Chrome handling is actually less elegant - the global history stack simply breaks. See https://bugs.chromium.org/p/chromium/issues/detail?id=705550. Also, there are some security implications as described in the https://bugs.chromium.org/p/chromium/issues/detail?id=705583. |
I've run into this while playing around with the flagged implementation in Canary. I want to be able to do: A -> B (adopt A) <- (back button) -> A While retaining the same history as you would get if portals were not used. |
A few points raised by @annevk that relate to history: History currently hangs off the browsing context (and BC group) in the specification, but our current thinking on this would seem to allow navigating back to the history of a browsing context that has since been discarded (e.g. because it wasn't adopted). It might make sense to change how this association is structured so that history entries can survive. Also, we don't have as crisp an understanding as we would like about how |
Any updates on this? I think allowing back button to work is crucial for many adaptions. |
Implementation bug. Fixed in later Chrome releases, with more improvements coming down the pipe. See #163 (comment). |
When a portal is activated, its contents will take the whole tab, so it makes sense from a users perspective to treat this the same way we treat a navigation and add the portal's last entry to the session history. That ensures that the back button has a reasonably expected behavior, even though it may not be as seamless/smooth as the portal activation.
Other than that, we'll rely on the previous page to restore its state on back navigation, which can be accomplished by using push/replace state APIs before a portal activation.
The text was updated successfully, but these errors were encountered: