Skip to content

Commit

Permalink
fix(storefront): BCTHEME-193 fix not being able to change product qty…
Browse files Browse the repository at this point in the history
… with keyboard multiple times (bigcommerce#1927)

Co-authored-by: BC-tymurbiedukhin <66319629+BC-tymurbiedukhin@users.noreply.github.com>
  • Loading branch information
2 people authored and sacr3dc0w committed Mar 31, 2021
1 parent 1a2d75b commit df0387a
Show file tree
Hide file tree
Showing 2 changed files with 10 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 unable to change product quantity several times on cart page using keyboard. [#1927](https://github.com/bigcommerce/cornerstone/pull/1927)
- Cornerstone - loading of thumbnail image delayed on cart page . [#1925](https://github.com/bigcommerce/cornerstone/pull/1925)
- Added narrow down pricing during option selections [#1924](https://github.com/bigcommerce/cornerstone/pull/1924)
- Cornerstone - Image Zoom Does Not Work on Internet Explorer. [#1923](https://github.com/bigcommerce/cornerstone/pull/1923)
Expand Down
9 changes: 9 additions & 0 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ export default class Cart extends PageManager {
this.$cartTotals = $('[data-cart-totals]');
this.$overlay = $('[data-cart] .loadingOverlay')
.hide(); // TODO: temporary until roper pulls in his cart components
this.$activeCartItemId = null;
this.$activeCartItemBtnAction = null;

this.bindEvents();
}

cartUpdate($target) {
const itemId = $target.data('cartItemid');
this.$activeCartItemId = itemId;
this.$activeCartItemBtnAction = $target.data('action');

const $el = $(`#qty-${itemId}`);
const oldQty = parseInt($el.val(), 10);
const maxQty = parseInt($el.data('quantityMax'), 10);
Expand Down Expand Up @@ -220,6 +225,10 @@ export default class Cart extends PageManager {
const quantity = $('[data-cart-quantity]', this.$cartContent).data('cartQuantity') || 0;

$('body').trigger('cart-quantity-update', quantity);

$(`[data-cart-itemid='${this.$activeCartItemId}']`, this.$cartContent)
.filter(`[data-action='${this.$activeCartItemBtnAction}']`)
.trigger('focus');
});
}

Expand Down

0 comments on commit df0387a

Please sign in to comment.