Skip to content

feat: optimistic updates on add to cart#1445

Merged
deini merged 1 commit intomainfrom
optimistic-cart
Oct 11, 2024
Merged

feat: optimistic updates on add to cart#1445
deini merged 1 commit intomainfrom
optimistic-cart

Conversation

@deini
Copy link
Copy Markdown
Contributor

@deini deini commented Oct 10, 2024

What/Why?

Add to cart (in PDP, PLP, Compare) now supports some optimistic updates. We keep the loading spinner on the button but show the toast and update the badge right away.

If the request fails it will revert the changes and show the error toast.

Testing

a2fiM2fn.mp4

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 10, 2024

🦋 Changeset detected

Latest commit: 5488628

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 10, 2024

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

Name Status Preview Comments Updated (UTC)
catalyst 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 7:50pm
catalyst-latest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 7:50pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
catalyst-1millionproducts-store ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2024 7:50pm
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2024 7:50pm
catalyst-test-store ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2024 7:50pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2024 7:50pm
catalyst-unstable ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2024 7:50pm

@deini deini marked this pull request as ready for review October 10, 2024 19:51
@deini deini requested a review from a team October 10, 2024 19:51
Comment on lines +28 to +29
// Optimistic update
cart.increment(quantity);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍹 Just thinking it might be nice to explicitly mention it's an optimistic update with the fn name.

Suggested change
// Optimistic update
cart.increment(quantity);
cart.optimisticlyIncrement(quantity);

@deini deini added this pull request to the merge queue Oct 11, 2024
Merged via the queue into main with commit ba3f513 Oct 11, 2024
@deini deini deleted the optimistic-cart branch October 11, 2024 17:58
@github-actions github-actions Bot mentioned this pull request Oct 11, 2024
@github-actions
Copy link
Copy Markdown
Contributor

⚡️🏠 Lighthouse report

Lighthouse ran against https://catalyst-latest-o58ngai86-bigcommerce-platform.vercel.app

🖥️ Desktop

We ran Lighthouse against the changes on a desktop and produced this report. Here's the summary:

Category Score
🟢 Performance 99
🟢 Accessibility 100
🟢 Best practices 96
🟠 SEO 82

📱 Mobile

We ran Lighthouse against the changes on a mobile and produced this report. Here's the summary:

Category Score
🟢 Performance 97
🟢 Accessibility 100
🟢 Best practices 96
🟠 SEO 85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants