Re: history state (due to pushState) issues
Posted: Sun Jan 31, 2021 11:55 am
thinking about this problem over the weekend:
1. the current flow is that the IFrame basically changes location, right before it does - it sends the message to the parent. The parent does pushState, so you effectively have two states - the state actually generated by the click event and the second one that was created by the pushState.
2. I thought of a stupid workaround, basically hooking into the popState event and going back one extra time if it sees it was originally pushed by the code (pretty easy). The problem is that it looks like the popState event only gets called during the second (good) back command is issued. Still thinking about how to approach it.
3. This is what someone else did (it's a bit convoluted, basically removes the original request, creates a new cloned iframe off-DOM and then reconnects it, so it doesn't get entered into the history stack).
https://stackoverflow.com/questions/397 ... wo-entries
1. the current flow is that the IFrame basically changes location, right before it does - it sends the message to the parent. The parent does pushState, so you effectively have two states - the state actually generated by the click event and the second one that was created by the pushState.
2. I thought of a stupid workaround, basically hooking into the popState event and going back one extra time if it sees it was originally pushed by the code (pretty easy). The problem is that it looks like the popState event only gets called during the second (good) back command is issued. Still thinking about how to approach it.
3. This is what someone else did (it's a bit convoluted, basically removes the original request, creates a new cloned iframe off-DOM and then reconnects it, so it doesn't get entered into the history stack).
https://stackoverflow.com/questions/397 ... wo-entries