Skip to content
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

USWDS - Date Picker: Add high contrast focus styling to calendar button #5701

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

mahoneycm
Copy link
Contributor

@mahoneycm mahoneycm commented Jan 5, 2024

Summary

Adds focus styles to calendar button in high contrast mode. Now, the calendar icon changes to the highlight high contrast token.

Breaking change

This is not a breaking change.

Related issue

Closes #5535

Related pull requests

Changelog →

Preview link

Date Picker →

Problem statement

In high contrast mode, the date picker calendar button does not have a visible focus indicator when focused. It is still functional via keyboard but lacks context that it is focused.

Indicator is missing focus because the button is empty and relies on mask technique to set icon.

High contrast icons throughout the design system are mostly set as a mask using theadd-color-icon() mixin. We use this method to color the icon using high contrast tokens and ensure visibility throughout high contrast light/dark themes.

Because the mask covers the entire element, the focus indicator is covered by the mask as well.

Solution

Change the icon color to highlight on focus.

Possible downfalls

The default light-theme colors aren’t great and still make it hard to see that the color is focused. We could try another high contrast token but it feels beneficial to use highlight. Some users customize their high contrast theme and it’s important they recognize the color.

Alternatively, we could investigate other ways to place the icon and ensure visibility in high-contrast.

Major changes

Calendar icon changes color on focus in high contrast modes.

Testing and review

  1. Visit the date picker.
  2. Activate high contrast mode.
    • Chrome instructions. (creating doc)
  3. Use the tab key to focus the date picker button.
  4. Confirm icon changes color.
    • Color should match the focus border on the date input.

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

LGTM. Added note highlighting a future enhancement.

Comment on lines 143 to 147
&:not([disabled]) {
&:focus,
&:hover {
background-color: Highlight;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Note

In the future, we should consider high contrast styles in the partial, instead of per section. That way all buttons can benefit.

Copy link

@amycole501 amycole501 left a comment

Choose a reason for hiding this comment

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

I used a Chrome plug in to activate high contrast mode and it looked great. I could clearly see the outline of the calendar icon (mine was yellow).

@mahoneycm mahoneycm requested a review from amycole501 January 10, 2024 15:47
Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

@mahoneycm
I opened the component in forced color mode via the Chrome web inspector rendering panel. The icon now successfully changes color on focus.

I am not sure if this is a blocker, but I expected the icon to also receive a focus outline like it does in the standard viewing mode. Is there a reason it was not included here?

Of course I'll defer to @amycole501 on the WCAG standards for this.

image

@mahoneycm
Copy link
Contributor Author

@amyleadem Yes I included the reason it does not receive the focus outline in the problem statement!

Essentially the focus outline is covered due to the icon being placed as a mask. The mask covers the standard focus styles believe it or not.

For additional context, we're using an icon mask here so the icon color is updated and maintains contrast in light/dark modes.

@mahoneycm mahoneycm requested a review from amyleadem January 19, 2024 18:51
@amyleadem
Copy link
Contributor

Important

This issue is listed as a "known issue" in USWDS-Site: Add known issues to component pages. We should remove this item from the date picker page as part of our release documentation updates.

Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation, @mahoneycm! Looks good to me.

Note

@alex-hull referenced WCAG Technique C15 to confirm that a color change is enough to meet standards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USWDS - Bug: Date picker icon does not have visible focus indicator in high contrast mode
5 participants