Skip to content

Commit a7246a7

Browse files
committed
fix(shop): open cart drawer instantly on add-to-cart click
Drawer was waiting for the server round-trip (onSuccess) before opening — noticeable delay. Now opens immediately on click; onMutate bumps the badge in the same frame, and onSuccess populates the new line item when the server responds.
1 parent d5b1b4d commit a7246a7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/routes/shop.products.$handle.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,8 @@ function AddToCartButton({
334334
disabled={disabled}
335335
onClick={() => {
336336
if (!variant) return
337-
addToCart.mutate(
338-
{ variantId: variant.id, quantity },
339-
{ onSuccess: () => openDrawer() },
340-
)
337+
openDrawer()
338+
addToCart.mutate({ variantId: variant.id, quantity })
341339
}}
342340
className={twMerge(
343341
'mt-2 px-6 py-3 rounded-lg font-semibold transition-colors',

0 commit comments

Comments
 (0)