Fix cart item quantity change rollback#1418
Merged
junedkazi merged 1 commit intobigcommerce:masterfrom Jan 14, 2019
jbruni:patch-2
Merged
Fix cart item quantity change rollback#1418junedkazi merged 1 commit intobigcommerce:masterfrom jbruni:patch-2
junedkazi merged 1 commit intobigcommerce:masterfrom
jbruni:patch-2
Conversation
|
Autotagging @bigcommerce/storefront-team @davidchin |
|
Thanks @jbruni ! We'll get this reviewed. |
mattolson
approved these changes
Jan 11, 2019
Contributor
|
@jbruni Can you add a changelog entry, and then I'll merge this. |
junedkazi
approved these changes
Jan 14, 2019
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
This is a bug fix.
Context: change the quantity of a cart line item by manually editing the quantity input field value.
Currently, when a manual quantity change fails to succeed (for example, because it is greater than the maximum purchasable quantity), the quantity is reverted to zero in the input field.
It should rollback to the previous value. Not to zero.
This PR fixes this bug.
It is quite simple to see what is the problem in the code:
focusevent handler function,thisis used as a reference to the event target element (jQuery binds the event target element to the event handler function context);thisis not referencing the event target element, as it should, but the enclosing context (Cart class instance)Thus, the fix was also quite simple: only a matter of using a normal function. This way, we have the event target element properly bound to the function's
thiscontext. ThepreVal(previous value) variable is properly populated with the input's value.