Skip to content

Commit

Permalink
fix: drawer - typing in quantity and pressing enter empties cart (Sho…
Browse files Browse the repository at this point in the history
  • Loading branch information
treboryx authored and Thomas Timmers committed Aug 29, 2022
1 parent 2e6ec4e commit 8b0d44e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions assets/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CartItems extends HTMLElement {
sections_url: window.location.pathname
});

fetch(`${routes.cart_change_url}`, {...fetchConfig(), ...{ body }})
fetch(`${routes.cart_change_url}`, { ...fetchConfig(), ...{ body } })
.then((response) => {
return response.text();
})
Expand All @@ -87,7 +87,7 @@ class CartItems extends HTMLElement {
}));

this.updateLiveRegions(line, parsedState.item_count);
const lineItem = document.getElementById(`CartItem-${line}`) || document.getElementById(`CartDrawer-Item-${line}`);
const lineItem = document.getElementById(`CartItem-${line}`) || document.getElementById(`CartDrawer-Item-${line}`);
if (lineItem && lineItem.querySelector(`[name="${name}"]`)) {
cartDrawerWrapper ? trapFocus(cartDrawerWrapper, lineItem.querySelector(`[name="${name}"]`)) : lineItem.querySelector(`[name="${name}"]`).focus();
} else if (parsedState.item_count === 0 && cartDrawerWrapper) {
Expand All @@ -108,7 +108,6 @@ class CartItems extends HTMLElement {
if (this.currentItemCount === itemCount) {
const lineItemError = document.getElementById(`Line-item-error-${line}`) || document.getElementById(`CartDrawer-LineItemError-${line}`);
const quantityElement = document.getElementById(`Quantity-${line}`) || document.getElementById(`Drawer-quantity-${line}`);

lineItemError
.querySelector('.cart-item__error-text')
.innerHTML = window.cartStrings.quantityError.replace(
Expand Down Expand Up @@ -162,7 +161,7 @@ if (!customElements.get('cart-note')) {

this.addEventListener('change', debounce((event) => {
const body = JSON.stringify({ note: event.target.value });
fetch(`${routes.cart_update_url}`, {...fetchConfig(), ...{ body }});
fetch(`${routes.cart_update_url}`, { ...fetchConfig(), ...{ body } });
}, 300))
}
});
Expand Down
2 changes: 1 addition & 1 deletion snippets/cart-drawer.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
</quantity-input>

<cart-remove-button id="CartDrawer-Remove-{{ item.index | plus: 1 }}" data-index="{{ item.index | plus: 1 }}">
<button class="button button--tertiary" aria-label="{{ 'sections.cart.remove_title' | t: title: item.title }}">
<button type="button" class="button button--tertiary" aria-label="{{ 'sections.cart.remove_title' | t: title: item.title }}">
{% render 'icon-remove' %}
</button>
</cart-remove-button>
Expand Down

0 comments on commit 8b0d44e

Please sign in to comment.