Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Product Button: Remove the hardcoded width and padding #11537

Merged
merged 9 commits into from
Nov 7, 2023

Conversation

danieldudzic
Copy link
Contributor

@danieldudzic danieldudzic commented Nov 1, 2023

What

This PR removes the hardcoded button width and padding (to inherit the padding from the theme styling).

Fixes #11436

Why

Currently, the width of the buttons is hardcoded to 150px. My assumption is that this was introduced to prevent the following effect of "jumping width" because of the spinner:
279669403-8c05f08c-6101-44f8-b715-7cbe171b7910

The hardcoded width is less than ideal as it leads to issues like #11436.

Testing Instructions

Please consider any edge cases this change may have, and also other areas of the product this may impact.

  1. Add the 4-Column Product Row pattern to a post or a page.
  2. Go to the front end and try re-sizing the viewport.
  3. Make sure the buttons are not overflowing.
  4. Try adding products to the cart. Make sure there's no odd visual behavior.
  5. Go to the Shop page and make sure the buttons look and behave correctly.
  6. Try testing with regular, wide and full width.
  • Do not include in the Testing Notes
  • Should be tested by the development team exclusively

Screenshots or screencast

Before After
4-Column_Product_Row_–_newproductgallery 4-Column_Product_Row_–_newproductgallery

WooCommerce Visibility

Required:

  • WooCommerce Core
  • Feature plugin
  • Experimental
  • N/A

Checklist

Required:

  • This PR has either a [type] label or a [skip-changelog] label.
  • This PR is assigned to a milestone.

Conditional:

  • This PR has a changelog description (if [skip-changelog] label is not present).
  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces, and I've updated this doc.
  • This PR has been accessibility tested.
  • This PR has had any necessary documentation added/updated.

Changelog

Product Button: Improve the width and padding.

@danieldudzic danieldudzic added the type: bug The issue/PR concerns a confirmed bug. label Nov 1, 2023
@danieldudzic danieldudzic added this to the 11.5.0 milestone Nov 1, 2023
@danieldudzic
Copy link
Contributor Author

@jarekmorawski I'd appreciate your input regarding the proposed solution in this PR to the button width problem.

@woocommercebot woocommercebot requested review from a team and thealexandrelara and removed request for a team November 1, 2023 19:31
Copy link
Contributor

github-actions bot commented Nov 1, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-11537.zip

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 575
  • Total errors: 2487

🎉 🎉 This PR does not introduce new TS errors.

comments-aggregator

Copy link
Contributor

github-actions bot commented Nov 1, 2023

Size Change: -71 B (0%)

Total Size: 1.54 MB

Filename Size Change
build/all-products-rtl.css 4.54 kB -2 B (0%)
build/all-products.css 4.54 kB -3 B (0%)
build/cart-rtl.css 9.24 kB -12 B (0%)
build/cart.css 9.23 kB -12 B (0%)
build/product-button-rtl.css 1.14 kB -14 B (-1%)
build/product-button.css 1.14 kB -15 B (-1%)
build/wc-blocks-rtl.css 2.48 kB -7 B (0%)
build/wc-blocks.css 2.48 kB -6 B (0%)
ℹ️ View Unchanged
Filename Size
build/3810-frontend.js 18.3 kB
build/4124-frontend.js 23.9 kB
build/8280-frontend.js 8.48 kB
build/active-filters-frontend.js 6.69 kB
build/active-filters-rtl.css 1.68 kB
build/active-filters-wrapper-frontend.js 6.9 kB
build/active-filters-wrapper-rtl.css 1.53 kB
build/active-filters-wrapper.css 1.53 kB
build/active-filters.css 1.68 kB
build/active-filters.js 6.06 kB
build/add-to-cart-form-rtl.css 444 B
build/add-to-cart-form.css 444 B
build/all-products-frontend.js 9.68 kB
build/all-products.js 39.7 kB
build/all-reviews-rtl.css 1.75 kB
build/all-reviews.css 1.75 kB
build/all-reviews.js 7.8 kB
build/attribute-filter-frontend.js 19.9 kB
build/attribute-filter-rtl.css 4.03 kB
build/attribute-filter-wrapper-frontend.js 21.1 kB
build/attribute-filter-wrapper-rtl.css 1.65 kB
build/attribute-filter-wrapper.css 1.65 kB
build/attribute-filter.css 4.01 kB
build/attribute-filter.js 11.3 kB
build/base-components-stock-filter-wrapper~attribute-filter-wrapper~rating-filter-wrapper-style.scss-rtl.css 2.97 kB
build/base-components-stock-filter-wrapper~attribute-filter-wrapper~rating-filter-wrapper-style.scss.css 2.97 kB
build/blocks-checkout.js 33.9 kB
build/blocks-components.js 8.7 kB
build/breadcrumbs-rtl.css 234 B
build/breadcrumbs.css 234 B
build/breadcrumbs.js 2.13 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.4 kB
build/cart-blocks/cart-accepted-payment-methods-style.js 153 B
build/cart-blocks/cart-cross-sells-frontend.js 267 B
build/cart-blocks/cart-cross-sells-products-frontend.js 5.56 kB
build/cart-blocks/cart-cross-sells-products-style.js 153 B
build/cart-blocks/cart-cross-sells-style.js 269 B
build/cart-blocks/cart-express-payment-frontend.js 5.37 kB
build/cart-blocks/cart-express-payment-style.js 155 B
build/cart-blocks/cart-items-frontend.js 281 B
build/cart-blocks/cart-items-style.js 240 B
build/cart-blocks/cart-line-items-frontend.js 9.24 kB
build/cart-blocks/cart-line-items-style.js 153 B
build/cart-blocks/cart-order-summary-frontend.js 20.6 kB
build/cart-blocks/cart-order-summary-style.js 339 B
build/cart-blocks/cart-totals-frontend.js 296 B
build/cart-blocks/cart-totals-style.js 253 B
build/cart-blocks/empty-cart-frontend.js 376 B
build/cart-blocks/empty-cart-style.js 375 B
build/cart-blocks/filled-cart-frontend.js 614 B
build/cart-blocks/filled-cart-style.js 332 B
build/cart-blocks/order-summary-coupon-form-frontend.js 20.9 kB
build/cart-blocks/order-summary-coupon-form-style.js 155 B
build/cart-blocks/order-summary-discount-frontend.js 21 kB
build/cart-blocks/order-summary-discount-style.js 155 B
build/cart-blocks/order-summary-fee-frontend.js 288 B
build/cart-blocks/order-summary-fee-style.js 153 B
build/cart-blocks/order-summary-heading-frontend.js 347 B
build/cart-blocks/order-summary-heading-style.js 351 B
build/cart-blocks/order-summary-shipping-frontend.js 20.5 kB
build/cart-blocks/order-summary-shipping-style.js 154 B
build/cart-blocks/order-summary-subtotal-frontend.js 291 B
build/cart-blocks/order-summary-subtotal-style.js 154 B
build/cart-blocks/order-summary-taxes-frontend.js 456 B
build/cart-blocks/order-summary-taxes-style.js 202 B
build/cart-blocks/proceed-to-checkout-frontend.js 7.64 kB
build/cart-blocks/proceed-to-checkout-style.js 1.09 kB
build/cart-frontend.js 29 kB
build/cart.js 39.7 kB
build/catalog-sorting-rtl.css 259 B
build/catalog-sorting.css 259 B
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/actions-frontend.js 8.14 kB
build/checkout-blocks/actions-style.js 1.01 kB
build/checkout-blocks/billing-address-frontend.js 9.98 kB
build/checkout-blocks/billing-address-style.js 639 B
build/checkout-blocks/contact-information-frontend.js 1.7 kB
build/checkout-blocks/contact-information-style.js 653 B
build/checkout-blocks/express-payment-frontend.js 5.82 kB
build/checkout-blocks/fields-frontend.js 375 B
build/checkout-blocks/fields-style.js 342 B
build/checkout-blocks/order-note-frontend.js 681 B
build/checkout-blocks/order-summary-cart-items-frontend.js 6.48 kB
build/checkout-blocks/order-summary-cart-items-style.js 153 B
build/checkout-blocks/order-summary-coupon-form-frontend.js 20.9 kB
build/checkout-blocks/order-summary-coupon-form-style.js 155 B
build/checkout-blocks/order-summary-discount-frontend.js 21 kB
build/checkout-blocks/order-summary-discount-style.js 154 B
build/checkout-blocks/order-summary-fee-frontend.js 291 B
build/checkout-blocks/order-summary-fee-style.js 155 B
build/checkout-blocks/order-summary-frontend.js 20.6 kB
build/checkout-blocks/order-summary-shipping-frontend.js 20.6 kB
build/checkout-blocks/order-summary-shipping-style.js 154 B
build/checkout-blocks/order-summary-style.js 341 B
build/checkout-blocks/order-summary-subtotal-frontend.js 289 B
build/checkout-blocks/order-summary-subtotal-style.js 155 B
build/checkout-blocks/order-summary-taxes-frontend.js 455 B
build/checkout-blocks/order-summary-taxes-style.js 201 B
build/checkout-blocks/payment-frontend.js 14.5 kB
build/checkout-blocks/payment-style.js 509 B
build/checkout-blocks/pickup-options-frontend.js 11.2 kB
build/checkout-blocks/pickup-options-style.js 481 B
build/checkout-blocks/shipping-address-frontend.js 9.94 kB
build/checkout-blocks/shipping-address-style.js 517 B
build/checkout-blocks/shipping-method-frontend.js 1.97 kB
build/checkout-blocks/shipping-method-style.js 1.44 kB
build/checkout-blocks/shipping-methods-frontend.js 19 kB
build/checkout-blocks/shipping-methods-style.js 456 B
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/terms-style.js 1.03 kB
build/checkout-blocks/totals-frontend.js 339 B
build/checkout-blocks/totals-style.js 300 B
build/checkout-frontend.js 30.6 kB
build/checkout-rtl.css 8.43 kB
build/checkout.css 8.42 kB
build/checkout.js 42.8 kB
build/classic-shortcode-rtl.css 242 B
build/classic-shortcode.css 241 B
build/classic-shortcode.js 4.66 kB
build/collection-filters.js 2.74 kB
build/collection-price-filter-frontend.js 591 B
build/collection-price-filter-rtl.css 1.07 kB
build/collection-price-filter.css 1.07 kB
build/collection-price-filter.js 2.15 kB
build/customer-account-rtl.css 410 B
build/customer-account.css 409 B
build/customer-account.js 3.19 kB
build/featured-category-rtl.css 974 B
build/featured-category.css 973 B
build/featured-category.js 13.6 kB
build/featured-product-rtl.css 1.02 kB
build/featured-product.css 1.02 kB
build/featured-product.js 13.8 kB
build/filter-wrapper-frontend.js 14.6 kB
build/filter-wrapper-rtl.css 378 B
build/filter-wrapper.css 378 B
build/filter-wrapper.js 2.38 kB
build/handpicked-products.js 7.33 kB
build/legacy-template-rtl.css 240 B
build/legacy-template.css 240 B
build/legacy-template.js 7.85 kB
build/mini-cart-component-frontend.js 30.8 kB
build/mini-cart-contents-block/cart-button-frontend.js 1.86 kB
build/mini-cart-contents-block/cart-button-style.js 1.23 kB
build/mini-cart-contents-block/checkout-button-frontend.js 1.95 kB
build/mini-cart-contents-block/checkout-button-style.js 1.44 kB
build/mini-cart-contents-block/empty-cart-frontend.js 383 B
build/mini-cart-contents-block/empty-cart-style.js 387 B
build/mini-cart-contents-block/filled-cart-frontend.js 284 B
build/mini-cart-contents-block/filled-cart-style.js 287 B
build/mini-cart-contents-block/footer-frontend.js 3.87 kB
build/mini-cart-contents-block/footer-style.js 1.96 kB
build/mini-cart-contents-block/items-frontend.js 246 B
build/mini-cart-contents-block/items-style.js 250 B
build/mini-cart-contents-block/products-table-frontend.js 8.59 kB
build/mini-cart-contents-block/shopping-button-frontend.js 501 B
build/mini-cart-contents-block/shopping-button-style.js 361 B
build/mini-cart-contents-block/title-frontend.js 2.04 kB
build/mini-cart-contents-block/title-items-counter-frontend.js 1.74 kB
build/mini-cart-contents-block/title-items-counter-style.js 1.2 kB
build/mini-cart-contents-block/title-label-frontend.js 1.68 kB
build/mini-cart-contents-block/title-label-style.js 1.14 kB
build/mini-cart-contents-block/title-style.js 1.38 kB
build/mini-cart-contents-rtl.css 3.22 kB
build/mini-cart-contents.css 3.21 kB
build/mini-cart-contents.js 16 kB
build/mini-cart-frontend.js 2.35 kB
build/mini-cart-rtl.css 2.44 kB
build/mini-cart.css 2.44 kB
build/mini-cart.js 6.09 kB
build/order-confirmation-additional-information-rtl.css 367 B
build/order-confirmation-additional-information.css 367 B
build/order-confirmation-additional-information.js 1.58 kB
build/order-confirmation-billing-address-rtl.css 398 B
build/order-confirmation-billing-address.css 397 B
build/order-confirmation-billing-address.js 1.56 kB
build/order-confirmation-billing-wrapper.js 1.51 kB
build/order-confirmation-downloads-rtl.css 477 B
build/order-confirmation-downloads-wrapper.js 1.58 kB
build/order-confirmation-downloads.css 478 B
build/order-confirmation-downloads.js 1.91 kB
build/order-confirmation-shipping-address-rtl.css 399 B
build/order-confirmation-shipping-address.css 398 B
build/order-confirmation-shipping-address.js 1.56 kB
build/order-confirmation-shipping-wrapper.js 1.52 kB
build/order-confirmation-status-rtl.css 280 B
build/order-confirmation-status.css 280 B
build/order-confirmation-status.js 1.55 kB
build/order-confirmation-summary-rtl.css 460 B
build/order-confirmation-summary.css 460 B
build/order-confirmation-summary.js 1.76 kB
build/order-confirmation-totals-rtl.css 594 B
build/order-confirmation-totals-wrapper.js 1.8 kB
build/order-confirmation-totals.css 593 B
build/order-confirmation-totals.js 2.18 kB
build/packages-style-rtl.css 5.18 kB
build/packages-style.css 5.19 kB
build/page-content-wrapper.js 1.96 kB
build/price-filter-frontend.js 7.94 kB
build/price-filter-rtl.css 2.68 kB
build/price-filter-wrapper-frontend.js 8.11 kB
build/price-filter-wrapper-rtl.css 2.53 kB
build/price-filter-wrapper.css 2.53 kB
build/price-filter.css 2.67 kB
build/price-filter.js 7.53 kB
build/price-format.js 913 B
build/product-add-to-cart-frontend.js 8.12 kB
build/product-add-to-cart-rtl.css 1.37 kB
build/product-add-to-cart.css 1.38 kB
build/product-add-to-cart.js 8.36 kB
build/product-average-rating-frontend.js 1.88 kB
build/product-average-rating.js 1.4 kB
build/product-best-sellers.js 7.07 kB
build/product-button-frontend.js 4.94 kB
build/product-button-interactivity-frontend.js 8.47 kB
build/product-button.js 4.66 kB
build/product-categories-rtl.css 654 B
build/product-categories.css 654 B
build/product-categories.js 2.6 kB
build/product-category.js 8 kB
build/product-collection.js 13.5 kB
build/product-details-rtl.css 397 B
build/product-details.css 394 B
build/product-gallery-frontend.js 837 B
build/product-gallery-large-image-frontend.js 616 B
build/product-gallery-large-image-next-previous.js 4.25 kB
build/product-gallery-large-image.js 2.47 kB
build/product-gallery-pager.js 3.48 kB
build/product-gallery-rtl.css 1.26 kB
build/product-gallery-thumbnails.js 3.9 kB
build/product-gallery.css 1.26 kB
build/product-gallery.js 9.57 kB
build/product-image-frontend.js 2.89 kB
build/product-image-gallery-rtl.css 307 B
build/product-image-gallery.css 306 B
build/product-image-rtl.css 996 B
build/product-image.css 994 B
build/product-image.js 2.57 kB
build/product-new.js 7.33 kB
build/product-on-sale.js 7.32 kB
build/product-price-frontend.js 2.82 kB
build/product-price-rtl.css 644 B
build/product-price.css 643 B
build/product-price.js 2.34 kB
build/product-query-rtl.css 350 B
build/product-query.css 349 B
build/product-query.js 11.7 kB
build/product-rating-counter-frontend.js 2.19 kB
build/product-rating-counter.js 1.7 kB
build/product-rating-frontend.js 2.53 kB
build/product-rating-rtl.css 247 B
build/product-rating-stars-frontend.js 2.43 kB
build/product-rating-stars-rtl.css 899 B
build/product-rating-stars.css 900 B
build/product-rating-stars.js 1.95 kB
build/product-rating.css 246 B
build/product-rating.js 2.04 kB
build/product-results-count-rtl.css 230 B
build/product-results-count.css 230 B
build/product-results-count.js 1.66 kB
build/product-reviews-rtl.css 458 B
build/product-reviews.css 458 B
build/product-sale-badge-frontend.js 2.01 kB
build/product-sale-badge-rtl.css 437 B
build/product-sale-badge.css 437 B
build/product-sale-badge.js 1.52 kB
build/product-search-rtl.css 419 B
build/product-search.css 417 B
build/product-search.js 2.62 kB
build/product-sku-frontend.js 2.02 kB
build/product-sku-rtl.css 240 B
build/product-sku.css 239 B
build/product-sku.js 1.53 kB
build/product-stock-indicator-frontend.js 2.2 kB
build/product-stock-indicator-rtl.css 232 B
build/product-stock-indicator.css 232 B
build/product-stock-indicator.js 1.71 kB
build/product-summary-frontend.js 2.36 kB
build/product-summary-rtl.css 549 B
build/product-summary.css 549 B
build/product-summary.js 1.88 kB
build/product-tag.js 7.52 kB
build/product-template-rtl.css 536 B
build/product-template.css 535 B
build/product-template.js 2.81 kB
build/product-title-frontend.js 2.31 kB
build/product-title-rtl.css 693 B
build/product-title.css 694 B
build/product-title.js 2.05 kB
build/product-top-rated.js 7.6 kB
build/products-by-attribute.js 8.05 kB
build/rating-filter-frontend.js 18.8 kB
build/rating-filter-rtl.css 4.09 kB
build/rating-filter-wrapper-frontend.js 19.7 kB
build/rating-filter-wrapper-rtl.css 1.73 kB
build/rating-filter-wrapper.css 1.73 kB
build/rating-filter.css 4.08 kB
build/rating-filter.js 5.8 kB
build/reviews-by-category-rtl.css 1.75 kB
build/reviews-by-category.css 1.75 kB
build/reviews-by-category.js 11.4 kB
build/reviews-by-product-rtl.css 1.75 kB
build/reviews-by-product.css 1.75 kB
build/reviews-by-product.js 12.7 kB
build/reviews-frontend.js 6.44 kB
build/single-product-rtl.css 378 B
build/single-product.css 378 B
build/single-product.js 11.1 kB
build/stock-filter-frontend.js 19 kB
build/stock-filter-rtl.css 3.88 kB
build/stock-filter-wrapper-frontend.js 20 kB
build/stock-filter-wrapper-rtl.css 1.49 kB
build/stock-filter-wrapper.css 1.49 kB
build/stock-filter.css 3.87 kB
build/stock-filter.js 6.44 kB
build/store-notices.js 1.68 kB
build/wc-blocks-classic-template-revert-button-style-rtl.css 240 B
build/wc-blocks-classic-template-revert-button-style.css 239 B
build/wc-blocks-classic-template-revert-button.js 1.19 kB
build/wc-blocks-data.js 19.7 kB
build/wc-blocks-editor-style-rtl.css 7.07 kB
build/wc-blocks-editor-style.css 7.07 kB
build/wc-blocks-google-analytics.js 1.16 kB
build/wc-blocks-jetpack-woocommerce-analytics.js 750 B
build/wc-blocks-middleware.js 735 B
build/wc-blocks-registry.js 2.75 kB
build/wc-blocks-shared-context.js 860 B
build/wc-blocks-shared-hocs.js 1.41 kB
build/wc-blocks-vendors.js 61.7 kB
build/wc-blocks.js 2.63 kB
build/wc-interactivity.js 10.7 kB
build/wc-payment-method-bacs.js 405 B
build/wc-payment-method-cheque.js 402 B
build/wc-payment-method-cod.js 508 B
build/wc-payment-method-paypal.js 439 B
build/wc-settings.js 2.4 kB
build/wc-shipping-method-pickup-location.js 29.4 kB

compressed-size-action

@jarekmorawski
Copy link

Looks good to me! Nice work, @danieldudzic. 👏

The downside of this solution is that when there's not a lot of available width the buttons get quite high as their text wraps:

It's a good compromise and the difference is night and day when it comes to overall order and harmony.

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming it solves the problem, I really like that we are trying to make this kind of visual improvements. 👏 Code-wise the PR looks good to me. The only concern I have is that now it's quite easy for words to break into two lines (screenshots from TT3):

(See how the word products in the second button is broken even though there is enough horizontal space for it)

After thinking about this, I think there are two approaches that we could investigate:

  1. It looks like these buttons have word-break: break-word. I'm not sure why is that, but maybe it's safe to remove it? I did a quick test and IMO it looks better:
  1. Given that with this PR we are adding margin to the :before and :after, I wonder if it would make sense to remove the default horizontal padding from the button. I mean, specifically setting it to 0 so the theme padding doesn't add on top of the :before and :after margins. Do you think that would work? (If we go that route, I'm not sure if it would be better to do it via global styles or directly in CSS)
Before After
imatge imatge

@danieldudzic
Copy link
Contributor Author

@Aljullu thanks for testing!

  1. Getting rid of the word-break: break-word will result in the following overflow issues:
4-Column_Product_Row_–_newproductgallery
  1. If we remove the padding, the spinner will not have sufficient padding and will look bad:
Shop_–_newproductgallery

@Aljullu
Copy link
Contributor

Aljullu commented Nov 3, 2023

Thanks for checking and good catch with those issues, @danieldudzic!

  1. If we remove the padding, the spinner will not have sufficient padding and will look bad:

A quick fix could be to move the spinner a little bit to the left. I think that way it might look "aligned" without needing to have double horizontal padding.


However, the more I think about this, the more I think we shouldn't work-around the "jumping width" issue. The reason I'm mentioning that is because:

  1. Adding margin to :left and :right might feel confusing for users. Ie, in the editor they might set a specific horizontal padding for the button but then, in the frontend there is this :left and :right margins which are added on top of that padding. I see how this can be confusing, specially as there is no way to remove it.
  2. Having margin for :left and :right means we have less space for the button text, which is what causes words to break into two lines.

So my proposal would be to remove the hard-coded 150px width as you did, but not try to fix the "jumping width" issue (because of the issues mentioned above).

I know that's not ideal. So in the future, we could consider changing this spinner effect (which causes the "jumping width" issue) for something else: either simply disabling the button while "adding to cart" or doing something like the Proceed to Checkout button of the Cart block, which allows keeping the button the same size:

Enregistrament.de.pantalla.des.de.2023-11-03.10-39-32.webm

Of course, that would need design input and it's out of the scope of this PR. But I feel that would be the more future-proof solution, as the current Add to Cart spinner will always either cause the "jumping width" issue or need some extra padding which might be confusing with global styles. What do you think?

@danieldudzic
Copy link
Contributor Author

@Aljullu

A quick fix could be to move the spinner a little bit to the left. I think that way it might look "aligned" without needing to have double horizontal padding.

This would also require some smart adjusting of padding/margins so that the width of the button doesn't jump. Potentially should be possible.

So my proposal would be to remove the hard-coded 150px width as you did, but not try to fix the "jumping width" issue (because of the issues mentioned above).

I normally would agree with you, but here we have a situation where the button currently doesn't jump because of the static width. So that change will alter the existing behavior and the buttons will start jumping.

So in the future, we could consider changing this spinner effect

Yes, I believe a design exploration into this would be useful. I like the spinner replacing the text altogether.


I think the proposed margin solution in this PR could be an interim fix to the overflow issue. But I don't feel strongly one way or another :)

@mikejolley
Copy link
Member

Moving to 11.6.0

@mikejolley mikejolley modified the milestones: 11.5.0, 11.6.0 Nov 6, 2023
@Aljullu
Copy link
Contributor

Aljullu commented Nov 6, 2023

@danieldudzic

I normally would agree with you, but here we have a situation where the button currently doesn't jump because of the static width. So that change will alter the existing behavior and the buttons will start jumping.

Yeah... I see what you mean, but at the same time, any CSS change that we make will alter the existing behavior. In trunk, the Add to Cart button has a fixed width of 150px while in this PR it doesn't, so that's already an alteration of the existing behavior. In my opinion, it's definitely worth it, given that the hard-coded width has several issues, as you mentioned in #11436.

However, given that we need to alter the existing behavior no matter what, I think we should move towards the solution that we feel will be more future-proof and cause less issues with existing themes. I'm advocating for removing the hard-coded width while not adding margin to :before and :after for some reasons:

  1. It doesn't add a horizontal padding that users can't remove. I think it's confusing for merchants to edit the horizontal padding of the button to find out that there are some invisible elements (::before and ::after) which are adding padding without any way to control that. If a store wanted to show a "Learn more" button next to the "Add to Cart" button, there would be no easy way to make them have the same horizontal padding if the "Add to Cart" button has ::before and ::after margins while the "Learn more" button doesn't.
  2. Not setting a margin to ::before and ::after elements allows us to change the animation of the Add to cart interaction without breaking existing buttons in the future. In other words, if we add a margin to the ::before and ::after pseudoelements and, in the future, we want to move to an animation like the one from the Proceed to Checkout buttons I mentioned above, what would we do with the ::before and ::after margins? Keeping them (even though they won't be needed anymore) or removing them (with the risk of breaking existing stores which might have set the button padding to 0)?
  3. I also think that adding margin to the ::before and ::after pseudoelements might be dangerous. They have been there for a long time, and we can't know how different themes use them. For example, I think this PR breaks the buttons on Storefront because SF hides the ::after element: (might be worth verifying, I might have done something wrong)
    imatge

Let me know what you think! Also, happy to jump in a sync-combo if you prefer. 🙂 I acknowledge my proposal is not perfect, but I consider the pros of not adding margins to ::before and ::after to outweigh the regression in the "jumping width" issue that would be introduced. We could also ask for some design direction if needed.

@danieldudzic
Copy link
Contributor Author

@Aljullu All valid points. Thank you for championing a better Add to Cart button experience 🙏 I'm happy to follow your proposed direction on this. Even with the drawbacks, the "jumping-width" button solution seems to be a bit more robust.

@danieldudzic danieldudzic requested a review from Aljullu November 6, 2023 17:38
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on TT1, TT2, TT3, TT4 and Storefront and it looks great on all of them! Thanks for the update, @danieldudzic! 🚢

@danieldudzic danieldudzic enabled auto-merge (squash) November 7, 2023 10:40
@danieldudzic danieldudzic merged commit b7a128b into trunk Nov 7, 2023
32 checks passed
@danieldudzic danieldudzic deleted the fix/11436-button-width branch November 7, 2023 17:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4-Column Product Row pattern: Button overflow
4 participants