Skip to content

Commit cc2f8ca

Browse files
authored
Defer cart watcher to next tick to avoid race condition (#1006)
1 parent 7c40a44 commit cc2f8ca

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

resources/js/stores/useCart.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,11 @@ export const taxTotal = (cart) => {
287287
return cart.prices.applied_taxes.reduce((sum, tax) => sum + tax.amount.value, 0)
288288
}
289289

290-
watch(mask, refresh)
291-
if (cartStorage.value?.id && !mask.value) {
292-
clear()
293-
}
290+
window.setTimeout(() => {
291+
watch(mask, refresh)
292+
if (cartStorage.value?.id && !mask.value) {
293+
clear()
294+
}
295+
})
294296

295297
export default () => cart

0 commit comments

Comments
 (0)