Skip to content

Commit

Permalink
fix(storefront): BCTHEME-1757 Anchor links on category pages are not …
Browse files Browse the repository at this point in the history
…working when product filtering is enabled
  • Loading branch information
VladDlogush committed Jan 15, 2024
1 parent a9b47cd commit a693826
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Draft
- Anchor links on category pages are not working when product filtering is enabled [#2415](https://github.com/bigcommerce/cornerstone/pull/2415)
- Dispatch an event on productOptionsChanged [#2400](https://github.com/bigcommerce/cornerstone/pull/2400)
- Check lang helpers usage and existence of key in translation file [#2403](https://github.com/bigcommerce/cornerstone/pull/2403)
- Display fees on cart page [#2376](https://github.com/bigcommerce/cornerstone/pull/2376)
Expand Down
11 changes: 2 additions & 9 deletions assets/js/theme/common/faceted-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,8 @@ class FacetedSearch {
}

onPopState() {
const currentUrl = window.location.href;
const searchParams = new URLSearchParams(currentUrl);
// If searchParams does not contain a page value then modify url query string to have page=1
if (!searchParams.has('page')) {
const linkUrl = $('.pagination-link').attr('href');
const re = /page=[0-9]+/i;
const updatedLinkUrl = linkUrl.replace(re, 'page=1');
window.history.replaceState({}, document.title, updatedLinkUrl);
}
if (document.location.hash !== '') return;

$(window).trigger('statechange');
}
}
Expand Down

0 comments on commit a693826

Please sign in to comment.