-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Load size units to show them as a suffix of shipping dimensions fields #34856
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
Conversation
Test Results SummaryCommit SHA: fa2e2cb
To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
e2bee57 to
50d217e
Compare
louwie17
left a comment
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.
Nice work @mdperez86, this tested well and looked good!
I did leave several comments, one small one around styling and a couple in relation to the BaseControl wrapper, which I don't think is necessary.
Outside of that, nice work on the Form updates and consolidating some of the styling and removing some of the duplicate styling.
| const resetForm = ( | ||
| newInitialValues: Values, | ||
| newChangedFields = {}, | ||
| newInitialValues = {} as Values, |
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.
Removing the newChangedFields param is probably ok, given I added the additional params just a month ago.
We do have to be careful removing those in the future, for backwards compability.
| } | ||
|
|
||
| &__content { | ||
| padding: $gap-large; |
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.
It's fine to remove some of these and replace it with the Card component, but the Card component styling is slightly different. It's top/bottom margin is smaller 16px versus 24px and the border-radius a little bit less.
So maybe add the padding and border-radius back for this and target the .components-card specifically.
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.
done
| <BaseControl | ||
| { ...regularPriceProps } | ||
| id="product_pricing_regular_price" | ||
| > |
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.
Is there a reason why these fields need to be wrapped in a BaseControl component? and why the BaseControl component needs the same props?
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.
Left another comment further down in relation to this, I don't think it's necessary.
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.
now it's a little more explicit why I was using BaseControl
| label={ __( 'Shipping class', 'woocommerce' ) } | ||
| { ...getTextControlProps( | ||
| getInputProps( 'shipping_class' ) | ||
| <> |
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 don't think this Fragment is necessary is it? Given everything is wrapped within the ProductSectionLayout.
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.
Ohh, that's right. Thanks.
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.
Done
| </p> | ||
| <div className="product-shipping-section__container"> | ||
| <div> | ||
| <BaseControl |
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 don't think the BaseControl is needed for wrapping each InputControl. The logic within BaseControl is already integrated within the InputControl if you look at the label code for example:
BaseControl: https://github.com/WordPress/gutenberg/blob/trunk/packages/components/src/base-control/index.tsx#L52-L73
InputControl: https://github.com/WordPress/gutenberg/blob/trunk/packages/components/src/input-control/label.tsx
Was this recommended somewhere else?
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 wrapped each InputControl with BaseControl for 2 reasons.
- Other TextControls we are using they are all wrapped within the BaseControl as you can see here.
- InputControl does not have the help feature which is used to show error messages and it's spaces styles are not the same as the TextControl we are using.
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.
Other TextControls we are using they are all wrapped within the BaseControl as you can see here.
Yeah, although the InputControl is suppose to replace this TextControl so maybe the help feature needed as part of your second point will still get added to the InputControl. I guess we should keep an eye out during any WordPress updates for this.
I think it would be worth to make our own InputControl wrapper that acts much like the TextControl you referenced, that wraps the BaseControl already. So in the case were WordPress does add this on update we only have one spot to update, and not a bunch of places.
But I acknowledge this would be out of the scope of this PR and can be done as a follow up.
| const valuesToSet: Values = {} as Values; | ||
| valuesToSet[ name as keyof Values ] = value; | ||
| setValues( valuesToSet ); | ||
| setValues( _setWith( { ...values }, name, value, _clone ) ); |
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.
cc @joshuatf in relation to the lodash usage, I know you are less of a fan of using lodash.
This does allow us to reference fields in this manner dimensions.width which is very handy, for the shipping field for example.
We could potentially implement this manually, but given lodash would be much more stable, I would be fine with using this (given we aren't pruning it out yet).
But let me know if you have any strong sense against this?
louwie17
left a comment
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.
Looks good @mdperez86, I just left one comment with a small bug I found now with separating the props out for the shipping dimensions. The onBlur is missing, which is required for the help text to show.
| 'woocommerce' | ||
| ) | ||
| ) } | ||
| onChange={ ( value: string ) => |
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.
You also want to pass in the onBlur callback to the InputControl as otherwise the help text doesn't show up.
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.
Done
b525da8 to
458fcb3
Compare
louwie17
left a comment
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.
Nice work @mdperez86, it's looking great now, thanks for your hard work on this 👍
Change the FormComponent to support input name with dot notation like dimensions.width Add the dimension controls to the product form
458fcb3 to
fa2e2cb
Compare
louwie17
left a comment
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.
Re-approving after rebase.
|
Hi @mdperez86, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:
|
All Submissions:
Changes proposed in this Pull Request:
Load dimensions and weight units to show them as a suffix of shipping dimensions fields, so the user will know a reference of which unit of the product dimensions will be used. These units are comming from WooCommerce > Settings > Products configuration.
Partialy closes #34329.
How to test the changes in this Pull Request:
Other information:
pnpm changelog add --filter=<project>?FOR PR REVIEWER ONLY: