Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Conversation

ginabak
Copy link
Contributor

@ginabak ginabak commented Nov 30, 2020

WHY are these changes introduced?

Fixes #3638 (when selected Tab is focused (on keyboard), it has a grey underline instead the primary green)

WHAT is this pull request doing?

A11y related: when auditing online-store-ui's PanelCard component (see Initial Audit #2291) we noticed that during the manual keyboard testing, when the selected tab is focused, the ::before underline was grey instead of the primary green --p-action-primary colour.

BEFORE

beforeTabs

AFTER

afterTabs

Please note the following:

  • the changes follow the pre new design language traits:
    • focus state is a lighter hue from the selected state instead of grey (pre changes)
    • the grey underline is only during a hover state
      preDesignTab

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

  1. Test new changes after pulling branch in this playground (post dev s)

🎩 checklist

  • Tested on mobile
    • tested on Google Pixel 2 XL (with TalkBack on Android)✅
  • Tested on multiple browsers
    • tested on Windows10 Edge ✅
    • tested on FireFox ✅
    • tested on Chrome ✅
    • tested on Safari ✅
  • Tested for accessibility
    • tested Voiceover on MacOS (Safari) ✅
    • tested JAWs on Windows (Chrome) ✅
    • tested Windows High Contrast (Edge) ❓ (going to post screenshot - not sure what the best is possibly a thicker border)
    • tested Zoom on MacOS (FireFox) ❓(see comment below)
  • Updated the component's README.md with documentation changes
  • Tophatted documentation changes in the style guide
  • For visual design changes, pinged one of @ HYPD, @ mirualves, @ sarahill, or @ ry5n to update the Polaris UI kit

@ghost
Copy link

ghost commented Nov 30, 2020

👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 30, 2020

🟢 This pull request modifies 2 files and might impact 1 other files.

Details:
All files potentially affected (total: 1)
📄 UNRELEASED.md (total: 0)

Files potentially affected (total: 0)

🎨 src/components/Tabs/Tabs.scss (total: 1)

Files potentially affected (total: 1)

@ginabak ginabak changed the title [WIP][a11][Tabs]: Fix a11y hover states [Tabs][a11y]: Fix a11y issue (when focus overrides selected state) Nov 30, 2020
- Added a `alwaysRenderCustomProperties` to `ThemeProvider` for elements that render outside of the DOM tree to their parent context ([#3652](https://github.com/Shopify/polaris-react/pull/3652))
- Increased precision of hue, saturation, lightness, and alpha in HSBLA `color-transformers` (https://github.com/Shopify/polaris-react/pull/3640)
- Fixed keyboard interactions for the `Tab` component ([#3650](https://github.com/Shopify/polaris-react/pull/3650))
- Fixed keyboard interaction when selected Tab was focused and rendering the wrong `::before` colour ([#3669](https://github.com/Shopify/polaris-react/pull/3669))
Copy link
Contributor Author

@ginabak ginabak Dec 1, 2020

Choose a reason for hiding this comment

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

Line 31 was my unreleased portion. I just moved the other ones in what I thought was the appropriate "sub heading" and changed the verb tenses to be past tense as per the Polaris Documentation Guideline

@ginabak ginabak requested a review from kyledurand December 1, 2020 02:26
@ginabak ginabak marked this pull request as ready for review December 1, 2020 02:27
@ginabak ginabak changed the title [Tabs][a11y]: Fix a11y issue (when focus overrides selected state) [Tabs][a11y]: Fix a11y keyboard interaction (when focus overrides selected state) Dec 1, 2020
}

.Tab-selected {
outline: 3px solid transparent;
Copy link
Contributor Author

@ginabak ginabak Dec 1, 2020

Choose a reason for hiding this comment

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

the reason I added a transparent outline was for Windows High Contrast Mode A11Y reasons:

This was BEFORE (it's hard to tell which one is ACTUALLY selected):
Capture

This is what it looks like AFTER(this is what it looks like now - it's very obvious):
{3E68B6E5-DDEE-4D6A-AD7B-01026F4465A3} png

NOT SURE if this is the best route would LOVE to know THOUGHTSSSS!

Copy link
Member

Choose a reason for hiding this comment

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

I would just wrap this in a media query so it only applies to high contrast mode. We can also be explicit about the color we use here by including our high contrast color mixin

Suggested change
outline: 3px solid transparent;
@media (-ms-high-contrast: active) {
outline: 3px solid ms-high-contrast-color('text');
}

ms-high-contrast-color('text') this will return the highest contrast value according to whatever the background color is set to. If the background is black, text will always be white etc... so we use this for borders / outlines and such.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oooh, I like this 👀 😄

Choose a reason for hiding this comment

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

We seem to be using this approach, media query + HC mixin, in a lot of places so I am all in favour of using it for consistency.

That said, it comes with some tradeoffs. The media query only works in Microsoft browsers so a user using WHCM in Chrome would still see the before experience.

The issue with the transparent outline is that even though the CSS property visually has no impact on the user, it is still rendered by the browser even when its not needed.

@ginabak
Copy link
Contributor Author

ginabak commented Dec 1, 2020

🎩 on Zoom on MacOS (FireFox):
ZoomTabs

In the GIF above, I'm using arrow keys but when I get to the last one it goes back to the first tab ... 🤭
... not sure how one accesses the three dots?! 🤯 OR ... if that's okay? I have a feeling it's not.

Copy link
Member

@kyledurand kyledurand left a comment

Choose a reason for hiding this comment

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

This looks awesome! I just left a comment around the high contrast stuff. Let me know if you have any questions about it 😄

Thanks Gina!

}

.Tab-selected {
outline: 3px solid transparent;
Copy link
Member

Choose a reason for hiding this comment

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

I would just wrap this in a media query so it only applies to high contrast mode. We can also be explicit about the color we use here by including our high contrast color mixin

Suggested change
outline: 3px solid transparent;
@media (-ms-high-contrast: active) {
outline: 3px solid ms-high-contrast-color('text');
}

ms-high-contrast-color('text') this will return the highest contrast value according to whatever the background color is set to. If the background is black, text will always be white etc... so we use this for borders / outlines and such.

Copy link
Contributor

@arapehl arapehl left a comment

Choose a reason for hiding this comment

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

Apart from Kyle's media query suggestion, everything else LGTM.

@ginabak
Copy link
Contributor Author

ginabak commented Dec 1, 2020

With the high contrast @media , this is what it looks like and looks much more clean in my opinion! 👀
YAY!

{8BF34ED7-1577-4136-A9B1-1BE28F7424DE} png

Copy link
Contributor

@beefchimi beefchimi left a comment

Choose a reason for hiding this comment

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

Quick comments.


&:active .Title::before {
background: var(--p-action-primary-pressed);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Space between blocks

}

@media (-ms-high-contrast: active) {
outline: 3px solid ms-high-contrast-color('text');
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does the 3px come from? Is this informed by somewhere else in Polaris? If so, is there a way to share that code? If not, you should at least wrap 3pm in the rem() function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was not informed by Polaris, I just did a quick search and I see on ActionList.scss that they use 1px:

outline: 1px solid ms-high-contrast-color('text');

}

@media (-ms-high-contrast: active) {
outline: rem(3px) solid ms-high-contrast-color('text');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@beefchimi 👀 how's this?

Copy link
Contributor

@beefchimi beefchimi left a comment

Choose a reason for hiding this comment

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

Have not been able to tophat, but code looks good 👍

@ginabak ginabak merged commit 270ef9d into master Dec 1, 2020
@ginabak ginabak deleted the gbak-tabs branch December 1, 2020 18:16
@ghost
Copy link

ghost commented Dec 1, 2020

🎉 Thanks for your contribution to Polaris React!

Copy link

@DanGodfrey DanGodfrey left a comment

Choose a reason for hiding this comment

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

🎉 awesome work 🙌

@emma-boardman
Copy link
Contributor

In the GIF above, I'm using arrow keys but when I get to the last one it goes back to the first tab ... 🤭
... not sure how one accesses the three dots?! 🤯 OR ... if that's okay? I have a feeling it's not.

I think this is ok - I would expect the three dots to be accessible via the tab key, rather than an arrow key. The arrow keys in this pattern is for moving specifically between the tab titles (the elements with role=tab). The three dots are button, rather than a tab title.

If I'm tabbing through the element in your gif as a whole, my first tab would focus the first role=tab element (which I can then navigate within using the arrow keys), and my second tab would focus the three-dot button (which I can then open using enter or space).

ErickTamayo pushed a commit that referenced this pull request Dec 7, 2020
…ected state) (#3669)

* Experiment Tabs.scss

* Fix issue when hover overwrites selected state - on keyboard and mouse hover

* Add unreleased.md

* Add transparent border for Windows High Contrast Mode

* Change focus to grey

* Change transparent border to wrap in media query

* Address Curtis comments -space and rem
sylvhama pushed a commit that referenced this pull request Mar 26, 2021
…ected state) (#3669)

* Experiment Tabs.scss

* Fix issue when hover overwrites selected state - on keyboard and mouse hover

* Add unreleased.md

* Add transparent border for Windows High Contrast Mode

* Change focus to grey

* Change transparent border to wrap in media query

* Address Curtis comments -space and rem
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New DL] Focused selected Tab has gray underline instead of green
6 participants