-
Notifications
You must be signed in to change notification settings - Fork 679
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
Fixes Checkout Shipping Methods Inadvertent Error Message #2371
Conversation
|
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.
A few minor changes but otherwise functional and works!
.selected_shipping_method; | ||
} catch (err) { | ||
// We don't have data from our specific query to fetch the selected shipping method. | ||
// Intentionally swallow this error. |
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.
Since we hide logs in production we can and should log the error just in case. Swallowing errors can make future us sad.
if (process.env.NODE_ENV === 'development') {
console.log(err);
}
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.
Fixed in 7318d2b.
This was never really an error worth showing anyone: I was using that try / catch
as a way not to have to check each object in chosenShippingMethodData.cart.shipping_addresses[0].selected_shipping_method
for existence but it turns out the only one we really have to check for is chosenShippingMethodData
itself, so I just went ahead and did that.
console.log( | ||
'selected method from list of methods', | ||
selectedMethod | ||
); // has all display data needed |
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.
console.log( | |
'selected method from list of methods', | |
selectedMethod | |
); // has all display data needed |
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.
Oops, thanks!
Fixed in 7318d2b.
@@ -46,11 +46,15 @@ const ShippingRadios = props => { | |||
return { label, value }; | |||
}); | |||
|
|||
// Match the serialization of method objects from the useShippingMethod talon. | |||
const { carrier_code, method_code } = selectedShippingMethod; | |||
const selectedShippingMethodSerializedValue = `${carrier_code}|${method_code}`; |
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.
This logic should probably move to useShippingRadios
and then be handled by some utility function that is shared between useShippingMethod
and useShippingRadios
talons.
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.
👍 I had the same thought and was on the fence about it.
Fixed in 7318d2b.
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.
A+
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.
Awesome 👍
Performance Test Results The following fails have been reported by WebpageTest. These numbers indicates a possible performance issue with the PR which requires further manual testing to validate. https://pr-2371.pwa-venia.com/venia-tops.html : LH Performance Expected 0.75 Actual 0.66 |
@supernova-at After selecting Shipping method if we change address to other country then > Previously selected shipping methods loads for a sec and then new available shipping method loads. |
Above mentioned will be handled separately. |
Description
This PR updates the way the Shipping Methods component on the Checkout page loads its data which solves two problems:
1. Incorrectly Showing Error State
The talon determines the proper
displayState
for the component to be in by looking atcart.shipping_addresses[0].selected_shipping_method
.But it was also inadvertently waiting for the results of fetching all shipping methods before setting a
selectedShippingMethod
.Therefore the
CompletedView
was being rendered before it had aselectedShippingMethod
, which caused it to show an error message; it didn't have any data to show.This PR updates how the talon sets
selectedShippingMethod
- it no longer waits for all shipping methods. This keeps the talon internally consistent and fixes the inadvertent display of an error message by theCompletedView
.2. Inefficiency
Previously it was only querying for
carrier_code
andmethod_code
of thecart.shipping_addresses.selected_shipping_method
.Therefore in order to display what it needed to in the
CompletedView
, it had to wait for the query that fetched all shipping methods to return, and then.find
theselected_shipping_method
in the list of all available methods.Instead, this PR modifies the query for
selected_shipping_method
to include all the fields it needs to display. This means theCompletedView
can render immediately without having to wait for all the shipping methods to load first.Related Issue
Closes PWA-550.
Acceptance
Verification Stakeholders
Specification
Verification Steps
Bug Resolution
/checkout
pageShipping Method Full Regression
Because this PR changes how the
selectedShippingMethod
is determined, the Shipping Method component should get a full regression, including:Screenshots / Screen Captures (if appropriate)
Checklist