Skip to content

Conversation

@dkotter
Copy link
Contributor

@dkotter dkotter commented Apr 19, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR changes the wrapping container around the single product image from using a figure tag to using a div tag. This is a change to help with accessibility, particularly for screen readers.

In addition to changing the tag, I've adjusted some CSS we have in place that impacts the Twenty Twenty Three and Twenty Twenty Two themes. This CSS was scoped to the figure tag so I've changed that scope to the div tag. As an alternative, we could change this to being scoped just based on the class and not the tag itself.

I've tested this change on Storefront v4.2.0 as well as Twenty Twenty Three v1.0. I've tested at various breakpoints and as far as I can tell, no styles were impacted as part of this change.

Note: I've marked this as a major change because if any existing themes are styling the figure tag directly instead of the class, those styles will no longer be applied. Not sure if that counts as a breaking change though.

Closes #37603

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Create a new product and add an image to that product (or use an existing product with an image)
  2. Go to the single product page for that product
  3. Ensure the image shows correctly and styling matches expectations
  4. Check the image at various breakpoints to ensure it all looks correct

In my testing, I had two windows open where I loaded a product without the changes in this PR and another window with the same product but after the changes made here. This allowed me to compare these two side-by-side to ensure they matched.

Screenshots

With figure tag using Storefront With div tag using Storefront
with-figure-tag-storefront with-div-tag-storefront
With figure tag using Twenty Twenty Three With div tag using Twenty Twenty Three
with-figure-twentytwentythree with-div-twentytwentythree

@github-actions github-actions bot added plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution labels Apr 19, 2023
@woocommercebot woocommercebot requested review from a team and rrennick and removed request for a team April 19, 2023 17:02
@jorgeatorres
Copy link
Member

@rrennick: For context, whenever you're reviewing this, we had a little discussion in Slack on whether this was a breaking change or not, and we think it's ok provided the template version is bumped, etc. Here's the link for your reading pleasure: https://woocommercecommunity.slack.com/archives/C052LGBQD1T/p1681941407318249.

@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Merging #37853 (924c871) into trunk (c5285ec) will increase coverage by 0.0%.
The diff coverage is 100.0%.

❗ Current head 924c871 differs from pull request most recent head 1fa2812. Consider uploading reports for the commit 1fa2812 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             trunk   #37853   +/-   ##
========================================
  Coverage     51.5%    51.5%           
+ Complexity   17283    17281    -2     
========================================
  Files          430      430           
  Lines        80037    80030    -7     
========================================
+ Hits         41216    41217    +1     
+ Misses       38821    38813    -8     
Impacted Files Coverage Δ
...ion2/class-wc-rest-order-refunds-v2-controller.php 89.7% <100.0%> (ø)

... and 3 files with indirect coverage changes

@rrennick
Copy link
Contributor

@dkotter Thanks for submitting this. You will have to check the SCSS for remaining 4 default themes for styles for the <figure>. In Twenty-twenty it's https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/client/legacy/css/twenty-twenty.scss#L526

@dkotter
Copy link
Contributor Author

dkotter commented Apr 20, 2023

@dkotter Thanks for submitting this. You will have to check the SCSS for remaining 4 default themes for styles for the <figure>. In Twenty-twenty it's https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/client/legacy/css/twenty-twenty.scss#L526

@rrennick This is already accounted for in each of those files (see https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/client/legacy/css/twenty-twenty.scss#L531 for one example). They have separate CSS for the figure tag and then right below that, they have CSS for the woocommerce-product-gallery__wrapper class, which is the class that is used on that figure tag (and now will be used on the div tag).

I think we want to leave the existing figure CSS to support the use case of sites that have overridden the single product image template and thus will still have the figure HTML

@rrennick
Copy link
Contributor

I think we want to leave the existing figure CSS to support the use case of sites that have overridden the single product image template and thus will still have the figure HTML

While I see where you are coming from, that isn't consistent with the changes to the Twenty-Twenty-Two/Three CSS. We should definitely be consistent across all the default themes.

From Slack discussion: The

>
could be considered a breaking change, but I’m not sure if we really enforce that in templates, other than bumping template version number.

WooCommerce adds a warning to both the WooCommerce > Status screen and the Plugins screen when a template is out of date. We do make changes to templates that are not 100% backward compatible.

@dkotter
Copy link
Contributor Author

dkotter commented Apr 21, 2023

While I see where you are coming from, that isn't consistent with the changes to the Twenty-Twenty-Two/Three CSS. We should definitely be consistent across all the default themes

I guess I'm not following what isn't consistent here? Happy to make any changes as needed but not exactly sure what you're referring to.

In our CSS for Twenty-Twenty-Two/Three, the existing code is:

figure.woocommerce-product-gallery__wrapper {
	margin: 0;
}

I've left the figure part but added div.woocommerce-product-gallery__wrapper to that. I can remove the figure if you think that is no longer needed.

The CSS for all other Twenty themes has these lines:

figure {
    margin: 0;
    padding: 0;
}

.woocommerce-product-gallery__wrapper {
    margin: 0;
    padding: 0;
}

While yes, this isn't the exact same as what is done in Twenty-Twenty-Two/Three, the end result in essence is the same (we target both the figure tag and any use of the woocommerce-product-gallery__wrapper class). If the idea is to try and make these lines as consistent as possible across all default themes, I can look to do that, was just trying to keep this PR as focused as possible and minimize risk of breaking styles.

Copy link
Contributor

@rrennick rrennick left a comment

Choose a reason for hiding this comment

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

@dkotter This looks great. Thanks for the help.

@rrennick rrennick merged commit dec3e66 into woocommerce:trunk Apr 25, 2023
@github-actions github-actions bot added this to the 7.8.0 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility Improvements ‣ Product Page ‣ Image HTML

4 participants