Skip to content
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

Back/Forward navigation broken in navigation-in-elements.md sample code #84

Open
sentience opened this issue Sep 26, 2019 · 0 comments
Open

Comments

@sentience
Copy link

sentience commented Sep 26, 2019

The How do I manage URL from a Browser.element? guide contains a bug in the sample code that will prevent browser Back/Forward buttons from working.

The popstate event listener is incorrectly attached to the document:

// Inform app of browser navigation (the BACK and FORWARD buttons)
document.addEventListener('popstate', function () {
    app.ports.onUrlChange.send(location.href);
});

This should be added to the window to work:

// Inform app of browser navigation (the BACK and FORWARD buttons)
window.addEventListener('popstate', function () {
    app.ports.onUrlChange.send(location.href);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant