-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Adapt the width of the pricing fields #35545
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: db05dc2
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
mattsherman
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 start on this @nathanss! I left a few comments/pointers to things you should consider to make this implementation a bit more robust. Mainly from a naming standpoint and using our standard breakpoint mixin and a standard breakpoint value.
| } | ||
| } | ||
|
|
||
| .woocommerce-field-width { |
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 class name feels too generic (I recognize we have other generic class names in this file... we should clean those up too in a future PR). Since it is in the pricing section, we should name it something like:
product-pricing-section__price-field
Or, move it somewhere more general, like https://github.com/woocommerce/woocommerce/blob/736593ef1526ac1aa5495851789690b26eb2d657/plugins/woocommerce-admin/client/products/product-page.scss and call it something like:
.woocommerce-add-product,
.woocommerce-edit-product {
.half-width-field {
// props go here
}
}
I'm not sold on the half-width-field... part of me likes it and part of me thinks we should list our the classname of every specific type of field that is going to use this instead. What do you think?
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'd say we keep like half-width-field specially since it seems we will be adding this to more fields in the future. We can change in the future if needed
| } | ||
|
|
||
| .woocommerce-field-width { | ||
| @media only screen and (max-width: 1032px) { |
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.
We should use the following instead:
@include breakpoint( '<960px' ) {
width: 100%;
}
Using the breakpoint mixin from https://github.com/woocommerce/woocommerce/blob/112b9ac67a12a86e33d1d9d47027c76f17522083/packages/js/internal-style-build/abstracts/_breakpoints.scss
Since that mixin doesn't support the 1032px breakpoint, we should check with @jarekmorawski to see what breakpoint we should use (960px feels right to me, and is the breakpoint where WP collapses the admin sidebar).
| > | ||
| <InputControl | ||
| { ...regularPriceProps } | ||
| className="woocommerce-field-width" |
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'd put this in currencyInputProps above. That way, it will get merged I believe, and not just override any other classes already set on the component via regularPriceProps or anything else up the chain.
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.
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.
Ah, wait... we are wrapping the InputControl in a BaseControl, and we are pulling out className to set on the BaseControl. So, I'd still suggest putting it in currencyInputProps, but only set it on either BaseControl or InputControl... not sure which one would be best, probably InputControl, since the label or help could be longer (as your screenshot shows).
Honestly, with what we are doing here with BaseControl and InputControl, we ideally should have a new component such as CurrencyInput that takes care of all of this. Otherwise, things are quickly going to get messy and difficult to maintain.
| > | ||
| <InputControl | ||
| { ...salePriceProps } | ||
| className="woocommerce-field-width" |
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.
Same as above.
| Significance: patch | ||
| Type: enhancement | ||
|
|
||
| Adapt the width of pricing fields in new product management experience |
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'd probably make this comment a little more specific. "Adapt" feels a bit vague.
|
@nathanss I notice the "Run lint checks" was canceled. Not really sure (sometimes that just happens, I think). You can re-run checks by clicking "Details" on the failing check and click the "Re-run jobs" button. Of course, pushing new commits will also trigger a re-run, so you don't really need to worry about this until you are at the state where you are looking for a "final" review! |
|
@mattsherman thanks for the mixin suggestions. Never used those before! |
| > | ||
| <InputControl | ||
| { ...regularPriceProps } | ||
| className="woocommerce-field-width" |
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.
Ah, wait... we are wrapping the InputControl in a BaseControl, and we are pulling out className to set on the BaseControl. So, I'd still suggest putting it in currencyInputProps, but only set it on either BaseControl or InputControl... not sure which one would be best, probably InputControl, since the label or help could be longer (as your screenshot shows).
Honestly, with what we are doing here with BaseControl and InputControl, we ideally should have a new component such as CurrencyInput that takes care of all of this. Otherwise, things are quickly going to get messy and difficult to maintain.
… it manually for the two currency fields
Sent as a parameter to getInputProps and getSelectControlProps to avoid overwriting any additional className
mattsherman
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.
Just a minor changelog update.
Other than that, looks good and tests well.
| Significance: patch | ||
| Type: enhancement | ||
|
|
||
| Change the width of pricing fields to 50% in big screens (>960px) in new product management experience |
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 should be updated since it is not just the pricing fields that are being updated.
| <CardBody> | ||
| <BaseControl | ||
| id="product_pricing_regular_price" | ||
| className={ regularPriceProps?.className ?? '' } |
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'm okay with this change. As mentioned before, ideally we should abstract away this <BaseControl> usage so we aren't directly using it here. That is for the future though.
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.
Thanks for updating the changelog. Looks good. Nice work!

All Submissions:
Changes proposed in this Pull Request:
Changes the width of the pricing fields based on the screen's width.
I'm not sure how we want to determine the width of the fields. @jarekmorawski mentioned the 1032px width rule on issue #35180, so that's what I adopted in the first place.
Closes #35538.
How to test the changes in this Pull Request:
Other information:
pnpm --filter=<project> changelog add?FOR PR REVIEWER ONLY: