Navigating back in browser doesn't update view with Ajax facets

Created on 5 September 2018, about 6 years ago
Updated 11 September 2023, about 1 year ago

Currently navigating back in the browser reloads the whole page, so we can get the correct filters & view again. This however only works on the first backward navigation, since the addEventListener for popstate is added in the click event.

So flow is as follows:
1. user clicks a few filters, url is updated accordingly, and window.addEventListener("popstate", function (e) {} is executed (since it is executed in the click handler).
2. User presses back, and browser reloads. No event listener is attached anymore.
3. User presses back again; view is not updated anymore since page doesn't reload anymore.

I propose we move the event listener outside of the click handler.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium sam.spinoy@gmail.com

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States jrb Raleigh-Durham Area, NC, USA

    Here's an update to the patch in #4 with the code that adds the event listener wrapped in a once() call so it doesn't get added multiple times (per the suggestion in #9).

  • πŸ‡¬πŸ‡§United Kingdom fonant

    Patch in #12 works nicely here to fix the problems with facet selections and the browser's Back button. Thanks!

Production build 0.71.5 2024