Skip to content

Commit

Permalink
Merge pull request #6233 from vuestorefront/#6226-cart-customer-canno…
Browse files Browse the repository at this point in the history
…t-insert-multi-digit-quantity-into-input

fix(core): add debounce for updateCartQuantity
  • Loading branch information
igorwojciechowski authored Aug 25, 2021
2 parents e50c7b1 + c31d998 commit d5072a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/core/docs/changelog/6226.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
description: 'Fix quantity input being immediately disabled after inserting single digit',
link: 'https://github.com/vuestorefront/vue-storefront/issues/6226',
isBreaking: false,
breakingChanges: [],
author: 'Igor Wojciechowski',
linkToGitHubAccount: 'https://github.com/igorwojciechowski'
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
:disabled="loading"
:qty="cartGetters.getItemQty(product)"
class="sf-collected-product__quantity-selector"
@input="updateItemQty({ product, quantity: $event })"
@input="updateQuantity({ product, quantity: $event })"
/>
</div>
</template>
Expand Down Expand Up @@ -123,6 +123,7 @@ import {
import { computed } from '@vue/composition-api';
import { useCart, useUser, cartGetters } from '<%= options.generate.replace.composables %>';
import { useUiState } from '~/composables';
import debounce from 'lodash.debounce';
export default {
name: 'Cart',
Expand All @@ -146,12 +147,16 @@ export default {
const totalItems = computed(() => cartGetters.getTotalItems(cart.value));
loadCart();
const updateQuantity = debounce(async ({ product, quantity }) => {
await updateItemQty({ product, quantity });
}, 500);
return {
updateQuantity,
loading,
isAuthenticated,
products,
removeItem,
updateItemQty,
isCartSidebarOpen,
toggleCartSidebar,
totals,
Expand Down

0 comments on commit d5072a7

Please sign in to comment.