catalyst icon indicating copy to clipboard operation
catalyst copied to clipboard

feat: debounce quantity form per cart line item

Open matthewvolk opened this issue 5 months ago • 3 comments

What/Why?

The updateLineItem server action can be spammed pretty easily due to the fact that we are optimistically updating the cart line items in response to increment, decrement, and delete actions. Quantity updates were a good candidate for debouncing, which is exactly what this PR adds. With that said, this PR does not fix the fact that users can still spam delete actions on line items. That will need to be a fix for another PR.

[!IMPORTANT] This PR changes the CounterForm component pretty drastically. For one, it removes the HTML <form> entirely. When reviewing this PR, we should weigh the impact of decisions like that, I'd be interested in hearing everyone's thoughts.

Fixes #2476

Testing

  1. Navigate to Preview URL
  2. Add a product to cart
  3. Navigate to Cart
  4. Open network panel
  5. Rapidly increase the quantity of a cart line item by 10
  6. Notice only one POST request to /cart is logged in the network panel.

Migration

🚧 TODO

matthewvolk avatar Jul 18 '25 21:07 matthewvolk

⚠️ No Changeset found

Latest commit: 3d8673232c1d4adeef27bf4a8f99333b5786384f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 18 '25 21:07 changeset-bot[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
catalyst-canary ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 9:32pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
catalyst ⬜️ Ignored (Inspect) Jul 18, 2025 9:32pm
catalyst-au ⬜️ Ignored (Inspect) Jul 18, 2025 9:32pm
catalyst-b2b ⬜️ Ignored (Inspect) Jul 18, 2025 9:32pm
catalyst-uk ⬜️ Ignored (Inspect) Jul 18, 2025 9:32pm

vercel[bot] avatar Jul 18 '25 21:07 vercel[bot]

Is this something we still want to merge? Can we rebase if so?

jorgemoya avatar Oct 28 '25 17:10 jorgemoya