This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Update item quantity if server result is different from client #5352
Merged
+31
−2
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rubikuserbot
requested review from
a team and
nielslange
and removed request for
a team
December 9, 2021 16:16
senadir
added
type: bug
The issue/PR concerns a confirmed bug.
block: cart
Issues related to the cart block.
labels
Dec 9, 2021
Size Change: +31 B (0%) Total Size: 840 kB
ℹ️ View Unchanged
|
nielslange
approved these changes
Dec 10, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚢
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 14, 2021
…mmerce#5352) * respect when quantity changes from up * add test
jonny-bull
pushed a commit
to jonny-bull/woocommerce-gutenberg-products-block
that referenced
this pull request
Dec 16, 2021
…mmerce#5352) * respect when quantity changes from up * add test
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our cart's quantity input (as well as our checkout inputs) have a data direction issues, they only bubble up updates, but don't take updates from the server, meaning once the input mounts, its internal state will not reset, even if the server returns a different result.
Such systemic issues are fixed in two ways:
react-query
uses) so you update the cache you have while you wait for the server to respond. This was complicated to do in this PR, and would probably need an additional action. It's worth exploring nevertheless.Fixes #5239
How to test the changes in this Pull Request:
You can test this with two methods,
recieveCart
and server updates.Copy the code in Cart item quantities not re-rendered when new values are passed down via the API #5239 into the bottom of
woocommerce-gutenberg-products-block.php
Add two products, Hoodie and Belt to your cart.
Updating once quantity should update the other when the server responds.
Add an item to your cart, go to cart.
In console, run this code:
It should update your item quantity to 5.
Changelog