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

Fix hover style on small checkboxes and radio buttons in High Contrast Mode #3777

Merged
merged 2 commits into from
Jul 4, 2023

Conversation

querkmachine
Copy link
Member

@querkmachine querkmachine commented Jun 9, 2023

Hover styles are currently not visible on 'small' checkbox and radio buttons in Windows High Contrast Mode, because the box-shadow property is ignored in High Contrast Mode.

This PR aims to fix that by also applying an outline attribute at the same time: transparent normally, but coloured in High Contrast Mode, so that a visual change still takes place on hover.

As outline is also used by the focus state, there is some possible overlap here, but given we additionally thicken the input border on focus, a visual distinction between hovered, focused, and simultaneously hovered and focused is retained.

Raised as a low vision usability issue by DAC in their recent audit of Frontend. Resolves #3695.

Before After
Checkbox (hovered) image image
Checkbox (focused) image image
Checkbox (hovered and focused) image image
Checkbox (hovered, focused and checked) image image
Radio (hovered) image image
Radio (focused) image image
Radio (hovered and focused) image image
Radio (hovered, focused and checked) image image

@querkmachine querkmachine requested a review from a team June 9, 2023 16:09
@querkmachine querkmachine self-assigned this Jun 9, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3777 June 9, 2023 16:10 Inactive
@querkmachine querkmachine changed the title Add outlines to small checkboxes and radio buttons in High Contrast Mode Fix hover style on small checkboxes and radio buttons in High Contrast Mode Jun 9, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3777 June 9, 2023 16:12 Inactive
@querkmachine querkmachine force-pushed the kg-radio-checkbox-outlines-high-contrast branch from 34d5b84 to 109fe7c Compare June 9, 2023 16:17
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3777 June 9, 2023 16:18 Inactive
@querkmachine querkmachine marked this pull request as ready for review June 9, 2023 16:27
@querkmachine querkmachine force-pushed the kg-radio-checkbox-outlines-high-contrast branch from 109fe7c to 3ce761f Compare June 9, 2023 16:48
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3777 June 9, 2023 16:49 Inactive
@36degrees
Copy link
Member

Thanks for picking this up!

I do have some mild reservations about using Highlight as a colour for hover states. Similar to how we try to reserve yellow only for focus states, I think it would make sense to do the same for Highlight.

I'm wondering if we could explore a few alternative options, possibly using a thinner dotted or dashed outline could work? Given the limited palette and reduced feature set of forced colours mode, I'd also consider simplifying things by not trying to cover the focused + hovered state, and instead just letting the focus state 'win'.

I think it would be worth having this reviewed by @davidc-gds and a designer too to make sure they're happy with the changes.

@querkmachine
Copy link
Member Author

I do have some mild reservations about using Highlight as a colour for hover states. Similar to how we try to reserve yellow only for focus states, I think it would make sense to do the same for Highlight.

In looking at the prior work (aka, Windows itself) in High Contrast Mode, it seems to be standard to use the Highlight colour for hovering. This is at least the case when hovering over checkboxes, radios, buttons, menu items, selects and toggles too.

A sample checkbox from Windows 10 High Contrast Mode. The label is being hovered, turning the checkbox's border blue.

A sample radio button from Windows 10 High Contrast Mode. The label is being hovered, turning the radio's border blue.

Interestingly, this means our usage of the colours is inverted compared to the Windows default, which uses white for focus states and Highlight for hover.

@dav-idc
Copy link

dav-idc commented Jun 19, 2023

this means our usage of the colours is inverted compared to the Windows default, which uses white for focus states and Highlight for hover.

Heya! Chiming in to give some thoughts that might help us make a decision, while not rethinking our entire high-contrast-mode focus and hover implementation.

In my view, a visible hover when using contrast themes (like Windows High Contrast Mode) in any format is better than no visible hover.

I am also thinking that some sort of visual change (dotted, dashed, thickness change) might satisfy that view though, as Ollie suggested.

@querkmachine
Copy link
Member Author

Yep! Not planning to reverse everything we have currently, just an interesting thing I noticed whilst experimenting 😅

@querkmachine
Copy link
Member Author

Updated the initial comment with a dashed line approach instead.

Note that I'm not applying any specific styles for the 'hovered and focused' states, this is just how they're turning out with the cascade the way it currently is, and documented for completion's sake.

@querkmachine querkmachine force-pushed the kg-radio-checkbox-outlines-high-contrast branch from 3ce761f to edb3e20 Compare June 19, 2023 12:57
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3777 June 19, 2023 12:57 Inactive
@owenatgov owenatgov added this to the v4.7.0 milestone Jun 23, 2023
@querkmachine
Copy link
Member Author

@CharlotteDowns @christopherthomasdesign @Ciandelle Sorry for another ask, but any particular views on the dashed border look in the top comment?

@christopherthomasdesign
Copy link
Member

Hey @querkmachine

I think I'm ok with this in theory, it's quite a neat solution to the problem and it maintains a feeling that moving from hover to focus adds more visual weight to the thing.

Are there any other components with hover states that should use this convention on high contrast mode too?

@owenatgov owenatgov removed this from the v4.7.0 milestone Jun 29, 2023
@querkmachine
Copy link
Member Author

@christopherthomasdesign I'm not sure, myself. It was flagged in this specific instance because we provide a hover style normally to compensate for the radios and checkboxes having a small visual target, but a large actual target area. This affordance didn't exist in High Contrast Mode.

There are a few other elements that have a hover style normally but don't in High Contrast Mode, but they also don't have an invisible target area, so it's not precisely the same circumstances as here.

@dav-idc
Copy link

dav-idc commented Jul 3, 2023

Based on this thread, it seems like there's agreement that this is a good solution that doesn't interfere with anything else. So I'd recommend we go for it! 👍

On @christopherthomasdesign's question about whether we have other hover-able interactive components where the hover isn't carrying over to the contrast-themed version (for example, when using Windows High Contrast Mode):

  • I've tested a few other components which might be worth considering, shown in the headings below
  • This feels like a larger exploration of hover states that might be better suited for after we wrap up this main radios / checkboxes hover piece

1. Button (Start)

Taken from this page: https://design-system.service.gov.uk/components/button/
(This is likely the case for all links styled as buttons)
On regular colours mode (not contrast themed), both the 'Start' button and the regular button get focus states. When contrast themed, the 'Start' button doesn't get a hover state change.

Regular button un-hovered:
image

Regular button hovered:
image

Start button un-hovered:
image

Start button hovered:
image

2. Accordion ('Show all' button)

Taken from this page: https://design-system.service.gov.uk/components/accordion/
On regular colours mode (not contrast themed), both the 'Show all' button and the individual accordion items get focus states. When contrast themed, the 'Show all' doesn't get a hover state change.

Accordion area un-hovered:
image

Accordion item hovered:
image

Accordion 'Show all sections' hovered:
image

3. Checkboxes

We already know this one (it's what this issues is about)

4. File upload

(This doesn't have a hover stat when contrast themed, but it's also a native browser control at the moment)

5. Radios

We already know this one (it's what this issues is about)

6. Select

Taken from this page: https://design-system.service.gov.uk/components/select/
Oddly, this one has a hover state when contrast themed with Windows High Contrast Mode, but it doesn't normally have a hover state.

Select un-hovered in high-contrast mode:
image

Select hovered in high-contrast mode:
image

Select un-hovered regularly:
image

Select hovered regularly:
image

7. Text input

We know these don't have hover states, in both contrast theme and regular theme.

8. Text area

We know these don't have hover states, in both contrast theme and regular theme.

@dav-idc
Copy link

dav-idc commented Jul 3, 2023

@querkmachine sorry to add another thought right after that previous one.

For the states where there's multiple things happening at once, would it make sense to combine the focus/active and hover state properties?

So make the dotted 'hover' outline use the 'highlight' blue colour when:

  • Checkbox (hovered and focused)
  • Checkbox (hovered, focused and checked)
  • Radio (hovered and focused)
  • Radio (hovered, focused and checked)

It would look a bit like this for the checkbox:
screenshot of checkbox item in Windows High Contrast Mode, showing a dashed hover indicator in the 'Highlight' focus colour

And this for the radio:
screenshot of radio item in Windows High Contrast Mode, showing a dashed hover indicator in the 'Highlight' focus colour

@querkmachine
Copy link
Member Author

@davidc-gds That seems a sensible change to me! Don't think it's too controversial either (I hope!)

Forced colour modes (like Windows High Contrast Mode) ignore the box-shadow styling we apply to small checkboxes and radio
buttons on hover.

This change adds an outline on hover too, so that a visual change still takes place upon hovering in High Contrast Mode.
@querkmachine querkmachine force-pushed the kg-radio-checkbox-outlines-high-contrast branch from edb3e20 to 2e0ac10 Compare July 4, 2023 08:27
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3777 July 4, 2023 08:27 Inactive
@christopherthomasdesign
Copy link
Member

Yeah all looks good to me 👍 thanks for the suggestions @davidc-gds 🙌

Copy link

@dav-idc dav-idc left a comment

Choose a reason for hiding this comment

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

Now that we've switched to the dotted outline concept for the hover enhancements, this feels like an overall positive improvement for accessibility when using contrast themes. ✅

I can't speak fully to the code portion of this and would recommend getting a developer to review as well, but from a glance it looks to change what we want to change and doesn't do anything extra.

@@ -282,6 +286,10 @@
// We use two box shadows, one that restores the original focus state [1]
// and another that then applies the hover state [2].
.govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
// Set different HCM colour when we have both hover/focus applied at once
@media screen and (forced-colors: active), (-ms-high-contrast: active) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Double checked to see if Autoprefixer does it now (just in case) but no.

Thanks for adding prefixes still. Adding another mention for:

@@ -282,6 +286,10 @@
// We use two box shadows, one that restores the original focus state [1]
// and another that then applies the hover state [2].
.govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
// Set different HCM colour when we have both hover/focus applied at once
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this boilerplate comment from other places Hightlight is used?

// When in an explicit forced-color mode, we can use the Highlight system
// color for the outline to better match focus states of native controls

Copy link
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

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

No blockers just some minor comments, looks brill 🙌

@querkmachine querkmachine merged commit e925f2a into main Jul 4, 2023
27 checks passed
@querkmachine querkmachine deleted the kg-radio-checkbox-outlines-high-contrast branch July 4, 2023 13:37
@romaricpascal romaricpascal mentioned this pull request Dec 8, 2023
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.

Hover states for checkboxes and radios aren't visible in Windows High Contrast Mode
7 participants