Open nicohery opened 8 months ago
Hello everyone, same issue here with hummingbird, also with paginated parameters ( ?page=2) when using the Back button. User is redirected to the previous page then instantly on a 404 page : myshop.fr/[object History]
I have identified the line of code that seems to cause the problem. File /src/js/modules/facetedsearch/update.ts line 98
if ($(Theme.selectors.listing.list).length) {
window.addEventListener('popstate', (e) => {
const {state} = e;
window.location.href = state && state.current_url ? state.current_url : history;
});
}
I have identified the line of code that seems to cause the problem. File /src/js/modules/facetedsearch/update.ts line 98
if ($(Theme.selectors.listing.list).length) { window.addEventListener('popstate', (e) => { const {state} = e; window.location.href = state && state.current_url ? state.current_url : history; }); }
Could you add this line after window.location.href to force a refresh, and test?
window.location.reload();
Edit: Without this popstate listener on back navigation the facet checkboxes selection state won't update based on the url change, that's why the window.location.href needs to be set, and force reloaded to avoid caching issues.
Type 'History' is not assignable to type 'string'. So it can't be set on window.location.href. Thats why we got [object%20History]
why not using:
if (state && state.current_url) {
window.location.href = state.current_url;
} else {
window.history.back();
}
Type 'History' is not assignable to type 'string'. So it can't be set on window.location.href. Thats why we got [object%20History]
why not using:
if (state && state.current_url) { window.location.href = state.current_url; } else { window.history.back(); }
I've tested this with the following,
Homepage -> Category page -> Changed price filter -> Back button
This returned me back to the homepage.
Describe the bug:
Navigating back using the browser's "Back" button after changing the product sort order on a product list page redirects the user to an incorrect URL:
/[object%20History]
. This issue disrupts the user's browsing experience by not correctly returning them to the previous state.Expected behavior:
Users should be redirected to the previous page with the initial state or sort order intact when using the browser's "Back" button. This behavior is expected to work seamlessly, similar to how it functions with the default PrestaShop theme.
Steps to reproduce the issue:
PrestaShop version(s) where the bug happened:
8.1.5
PHP version(s) where the bug happened:
8.1