Open glasserc opened 4 years ago
I tried to reproduce using your repo (to see if my current bug is related), but I wasn't able to. Both the browser back button, and the one you included in the view, work correctly for me (Chrome v 81).
Can someone else try to reproduce? That way, we can know if it's still an issue, or if this can be closed.
I was just able to reproduce this issue on Chrome 84 as well as Firefox nightly (82.0a1 (2020-08-31)). Since the underlying code hasn't changed, I don't see any reason why this issue would no longer be present.
To make it easier to visualize the events and verify that the issue still exists, I added code to the reproduction case that keeps a history of all UrlChanged messages and displays them.
STR:
npm run debug
/home
,/profile
,/reviews/the-century-of-the-self
Expected behavior:
A single UrlChanged message should appear with
/profile
as the URLActual behavior:
Two UrlChanged messages are produced: first
/reviews/the-century-of-the-self
and then/profile
I guess this is because of this call to
key()
: https://github.com/elm/browser/blob/1d28cd625b3ce07be6dfad51660bea6de2c905f2/src/Elm/Kernel/Browser.js#L192-L195Because the history API is asynchronous, the immediate call to
key()
will just send a message for the current page URL.