Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsitent cart items when using browser's back and forward navigation #1691

Open
pkubwiraBixlers opened this issue Jan 26, 2024 · 1 comment
Assignees
Labels

Comments

@pkubwiraBixlers
Copy link

pkubwiraBixlers commented Jan 26, 2024

What is the location of your example repository?

https://hydrogen.shop/cart (shopify hydrogen demo store)

Which package or tool is having this issue?

Hydrogen

What version of that package or tool are you using?

Not sure

What version of Remix are you using?

Not sure

Steps to Reproduce

when you add an item to the bag and go to the "/cart" route and remove the item from cart (the number of items in the cart is 0) if you use the browser's navigation button to go back to the whatever page you were on before and then use the browser to go forward (going back to the cart route) the item you previously deleted will be there and you can repeat this process indefinitely.

Expected Behavior

the removed item should not be back in the cart when you use the browser to forward navigate back to the cart becaude it had already been removed.

Actual Behavior

item comes back in the cart after having been removed

@michenly michenly added the cart label May 2, 2024
@blittle blittle self-assigned this May 6, 2024
@michenly
Copy link
Contributor

michenly commented May 6, 2024

Hi @pkubwiraBixlers sorry about the late reply.

The behaviour you are seeing is because pages (including /cart) are server rendered.
The browser does not re-fetch the page from server when you are going back and forth in the navigation.

We are playing with some idea of how to make this feel less broken, but it does always come with some performance trade off.

Is there any reason why you need to use the /cart route specially? Your end user should mostly be un-aware of the /cart route unelss they have JS disabled & the user clicks on cart. By default Hydrogen uses the cart side drawer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants