Skip to content

Commit

Permalink
fix(storefront): BCTHEME-207 fix focus on sort by
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-alexsaiannyi committed Jan 22, 2021
1 parent fdf0cff commit 17314ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Fixed focus for sort by dropdown on reloading page. [#1964](https://github.com/bigcommerce/cornerstone/pull/1964)
- Updated Cornerstone theme and respected variants to meet the verticals/industries documented in BCTHEME-387
- Fixed selecting certain option types which pushes window view to the bottom of the page. [#1959](https://github.com/bigcommerce/cornerstone/pull/1959)
- Fixed case when default option is out of stock add to cart button does not populate for in stock options. [#1955](https://github.com/bigcommerce/cornerstone/pull/1955)
Expand Down
13 changes: 13 additions & 0 deletions assets/js/theme/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@ export default class Category extends CatalogPage {
constructor(context) {
super(context);
this.validationDictionary = createTranslationDictionary(context);

window.addEventListener('beforeunload', () => {
if (document.activeElement.id === 'sort') {
window.localStorage.setItem('sortByStatus', 'selected');
}
});
}

onReady() {
const sortBySelector = $('#sort');

if (window.localStorage.getItem('sortByStatus')) {
sortBySelector.focus();
window.localStorage.removeItem('sortByStatus');
}

$('[data-button-type="add-cart"]').on('click', (e) => {
$(e.currentTarget).next().attr({
role: 'status',
Expand Down

0 comments on commit 17314ac

Please sign in to comment.