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

add fallback screen reader styles #3557

Merged
merged 2 commits into from Dec 17, 2020

Conversation

haszari
Copy link
Member

@haszari haszari commented Dec 16, 2020

Fixes #3265

This PR adds styling for screen-reader text elements. Usually this is handled by the theme. However if the theme doesn't have support the screen reader text may be rendered inline (which is not intended); these fallback styles ensure screen reader text is hidden by default, and provides :focus styles for when the text has focus and is being read.

The specifics of the styles are pasted direct from underscores, with some colours changed. Feedback welcome on how to generalise these so they are a minimal, safe fallback (i.e. should not be opinionated).

Accessibility

I've tested with Safari VoiceOver but I couldn't focus the element in normal use. Keen for some testing of this with various browsers/platforms and screen reader tech :)

Screenshots

Focused in chrome and safari:

Chrome

Safari

Notes:

  • I faked :focus using browser dev tools.
  • When unfocused, screen reader text should not be visible.

For comparison, here's a screenshot of the issue:

Screen Shot 2020-12-16 at 2 27 46 PM

How to test the changes in this Pull Request:

  1. Install a theme that doesn't provide screen reader styles. I built a new Bad Theme using Underscores and deleted the screen reader styles.
  2. Add checkout block to a page and stuff to cart.
  3. View checkout on front end - confirm .screen-reader-text is hidden by default and is helpful when using a screen reader.
  4. Test with other themes to ensure these styles don't conflict or cause issues.

Changelog

Fix: Added fallback styling for screen reader text.

@haszari haszari requested a review from a team as a code owner December 16, 2020 01:25
@haszari haszari requested review from mikejolley and Aljullu and removed request for a team December 16, 2020 01:25
@haszari haszari self-assigned this Dec 16, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2020

Size Change: +413 B (0%)

Total Size: 1.16 MB

Filename Size Change
build/editor-rtl.css 14.6 kB +18 B (0%)
build/editor.css 14.6 kB +17 B (0%)
build/style-rtl.css 18.6 kB +189 B (1%)
build/style.css 18.6 kB +189 B (1%)
ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 8.74 kB 0 B
build/active-filters.js 8.94 kB 0 B
build/all-products-frontend.js 34.7 kB 0 B
build/all-products.js 36.2 kB 0 B
build/all-reviews.js 9.77 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 3.3 kB 0 B
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 334 B 0 B
build/atomic-block-components/add-to-cart-frontend.js 9.02 kB 0 B
build/atomic-block-components/add-to-cart.js 7.53 kB 0 B
build/atomic-block-components/button-frontend.js 2.31 kB 0 B
build/atomic-block-components/button.js 839 B 0 B
build/atomic-block-components/category-list-frontend.js 471 B 0 B
build/atomic-block-components/category-list.js 475 B 0 B
build/atomic-block-components/image-frontend.js 1.68 kB 0 B
build/atomic-block-components/image.js 1.13 kB 0 B
build/atomic-block-components/price-frontend.js 2.29 kB 0 B
build/atomic-block-components/price.js 2.31 kB 0 B
build/atomic-block-components/rating-frontend.js 524 B 0 B
build/atomic-block-components/rating.js 530 B 0 B
build/atomic-block-components/sale-badge-frontend.js 859 B 0 B
build/atomic-block-components/sale-badge.js 863 B 0 B
build/atomic-block-components/sku-frontend.js 389 B 0 B
build/atomic-block-components/sku.js 394 B 0 B
build/atomic-block-components/stock-indicator-frontend.js 568 B 0 B
build/atomic-block-components/stock-indicator.js 572 B 0 B
build/atomic-block-components/summary-frontend.js 916 B 0 B
build/atomic-block-components/summary.js 925 B 0 B
build/atomic-block-components/tag-list-frontend.js 465 B 0 B
build/atomic-block-components/tag-list.js 471 B 0 B
build/atomic-block-components/title-frontend.js 1.21 kB 0 B
build/atomic-block-components/title.js 1.05 kB 0 B
build/attribute-filter-frontend.js 18.1 kB 0 B
build/attribute-filter.js 12.5 kB 0 B
build/blocks.js 3.49 kB 0 B
build/cart-frontend.js 77.1 kB 0 B
build/cart.js 40.7 kB 0 B
build/checkout-frontend.js 92.3 kB 0 B
build/checkout.js 43 kB 0 B
build/featured-category.js 7.76 kB 0 B
build/featured-product.js 9.98 kB 0 B
build/handpicked-products.js 7.38 kB 0 B
build/price-filter-frontend.js 14.9 kB 0 B
build/price-filter.js 10.4 kB 0 B
build/product-best-sellers.js 7.46 kB 0 B
build/product-categories.js 3.23 kB 0 B
build/product-category.js 8.4 kB 0 B
build/product-new.js 7.63 kB 0 B
build/product-on-sale.js 8.02 kB 0 B
build/product-search.js 3.55 kB 0 B
build/product-tag.js 6.57 kB 0 B
build/product-top-rated.js 7.6 kB 0 B
build/products-by-attribute.js 8.37 kB 0 B
build/reviews-by-category.js 11.8 kB 0 B
build/reviews-by-product.js 13.4 kB 0 B
build/reviews-frontend.js 9.38 kB 0 B
build/single-product-frontend.js 37.7 kB 0 B
build/single-product.js 10.1 kB 0 B
build/vendors--atomic-block-components/price-frontend.js 5.65 kB 0 B
build/vendors-style-rtl.css 1.05 kB 0 B
build/vendors-style.css 1.05 kB 0 B
build/vendors.js 434 kB 0 B
build/wc-blocks-data.js 6.89 kB 0 B
build/wc-blocks-middleware.js 931 B 0 B
build/wc-blocks-registry.js 2.39 kB 0 B
build/wc-payment-method-bacs.js 775 B 0 B
build/wc-payment-method-cheque.js 771 B 0 B
build/wc-payment-method-cod.js 866 B 0 B
build/wc-payment-method-paypal.js 813 B 0 B
build/wc-payment-method-stripe.js 12.1 kB 0 B
build/wc-settings.js 2.6 kB 0 B
build/wc-shared-context.js 1.53 kB 0 B
build/wc-shared-hocs.js 1.66 kB 0 B

compressed-size-action

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've tested with Safari VoiceOver but I couldn't focus the element in normal use. Keen for some testing of this with various browsers/platforms and screen reader tech :)

If you were using the Tab key, I think that's to be expected. Screen readers usually provide a different navigation method which is more "line-by-line" so you can navigate to non-focusable items. With Orca it's done with the arrow keys, I guess it's probably the same in other screen readers?

I tested removing the screen-reader-text styles from Storefront and I can confirm this PR adds a fallback so screen reader elements are hidden.

In order to test :focus styles, I converted the <FormStep> legend element into an a and it looked great:

imatge

My only concern is that we are introducing a new set of 'screen-reader' styles, which differs from the ones in other projects:

Not blocking merge, but do you think we could use one of those 👆 as the base instead of introducing a new one from underscores? 🙂

- tweak mixin to align with focus-reveal style
- add new mixin for focus-reveal style, since it is coupled to
visually-hidden mixin
@haszari
Copy link
Member Author

haszari commented Dec 16, 2020

My only concern is that we are introducing a new set of 'screen-reader' styles … we could use one of those 👆

Good thinking @Aljullu , I should have looked more carefully for prior art!

I've switched to using our (most local) visually-hidden() mixin. I also made a new mixin for the companion focus style, since they are coupled.

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.

Nice to see a new mixing for the focus state. I didn't re-test it but code changes look good. :shipit:

@haszari haszari merged commit a5de6f5 into trunk Dec 17, 2020
@haszari haszari deleted the fix/3265-fallback-screen-reader-styles branch December 17, 2020 19:05
@senadir senadir added focus: accessibility The issue/PR is related to accessibility. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. labels Dec 21, 2020
@senadir senadir added this to the 4.1.0 milestone Dec 21, 2020
@senadir senadir added the type: enhancement The issue is a request for an enhancement. label Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: accessibility The issue/PR is related to accessibility. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add styles for .screen-reader-text to cover themes that don't have that style defined
3 participants