-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Update focus outline color to meet WCAG 2.2 contrast standards #6854
base: develop
Are you sure you want to change the base?
Conversation
Generate changelog in
|
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like a borderline breaking change, since it has the potential to make UI snapshots fail. I don't think it could cause some cases to have worse contrast because the current focus color already does not have enough contrast with the extremes of the color spectrum
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as outdated.
This comment was marked as outdated.
// this should become default in bp6, providing new behavior as a class for now to avoid breaking changes | ||
// to focus colors | ||
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */ | ||
.bp5-focus-enhanced-contrast & { | ||
outline: $pt-focus-indicator-color solid 2px; | ||
} | ||
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */ | ||
.#{$ns}-dark.bp5-focus-enhanced-contrast & { | ||
outline-color: $pt-dark-focus-indicator-color; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just do it. I wouldn't call this a breaking change. If we do introduce this class, you should use #{$ns}
instead of bp5
, which is what this lint rule is trying to tell you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay cool, I wasn't sure the history of how careful we've been with minor things like this that could be viewed as a break.
Ack on the prefix - I hard coded bp5 since this was only intended to work for the bp5 version and removed in bp6, but will just remove this.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
-
Audit intent color contrast, used in
input-transition-shadow
-
Audit focus outline of all components (may leave for follow up PRs) - a few more here but highlighting some main ones:
-
Card
no focus state -
FileInput
no visual focus state -
Tree
items cannot be focused - Tag focus outline does not have offset like other components
-
-
Check on history of why components that appear like text inputs have a shadow focus style while other components have offset outline style
-
Consider Consider using
:focus-visible
instead of:focus
for styling focus states #6076 along with this PR, or as a follow up in the same release- This was already tagged a breaking change - we could consider at the next major version bump but not needed for now.
// this should become default in bp6, providing new behavior as a class for now to avoid breaking changes | ||
// to focus colors | ||
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */ | ||
.bp5-focus-enhanced-contrast & { | ||
outline: $pt-focus-indicator-color solid 2px; | ||
} | ||
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */ | ||
.#{$ns}-dark.bp5-focus-enhanced-contrast & { | ||
outline-color: $pt-dark-focus-indicator-color; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay cool, I wasn't sure the history of how careful we've been with minor things like this that could be viewed as a break.
Ack on the prefix - I hard coded bp5 since this was only intended to work for the bp5 version and removed in bp6, but will just remove this.
@@ -25,6 +25,10 @@ $pt-app-elevated-background-color: $light-gray4 !default; | |||
$pt-dark-app-elevated-background-color: $dark-gray3 !default; | |||
|
|||
$pt-outline-color: rgba($blue3, 0.6) !default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not changing this color because of the comment at the top of this file stating that is generally considered a breaking change. Perhaps we want to make an exception here...
commentBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
@@ -25,6 +25,11 @@ $pt-app-elevated-background-color: $light-gray4 !default; | |||
$pt-dark-app-elevated-background-color: $dark-gray3 !default; | |||
|
|||
$pt-outline-color: rgba($blue3, 0.6) !default; | |||
// 0.752 opacity to meet WCCAG 2.2 minimum contrast guidelines with all light-gray backgrounds in light theme | |||
// and all dark-gray backgrounds in dark theme | |||
$pt-focus-indicator-color: rgba($blue2, 0.752) !default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$blue2 on $white - 3.77:1 contrast
$blue2 on $light-gray1 - 3:1 contrast
// and all dark-gray backgrounds in dark theme | ||
$pt-focus-indicator-color: rgba($blue2, 0.752) !default; | ||
// dark theme opacity could be less and still meet minimum contrast, but keep 0.752 to stay consistent | ||
$pt-dark-focus-indicator-color: rgba($blue5, 0.752) !default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$blue5 on $black - 5.77:1 contrast
$blue5 on $dark-gray5 - 3.39:1 contrast
for comparison - $blue4 on $dark-gray5 - 2.24:1 contrast
@@ -15,14 +15,14 @@ $input-color-disabled: $button-color-disabled !default; | |||
$input-placeholder-color: $pt-text-color-muted !default; | |||
$input-background-color: $white !default; | |||
$input-background-color-disabled: rgba($light-gray1, 0.5) !default; | |||
$input-shadow-color-focus: $pt-intent-primary !default; | |||
$input-shadow-color-focus: $pt-focus-indicator-color; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this can't be relied on externally - remove and use $pt-focus-indicator-color
directly in the handful of places it's used. Same for dark theme version below.
Fixes no issue
Checklist
Changes proposed in this pull request:
Update color of focus outline to meet 3:1 contrast standard for UI component focus states
https://webaim.org/resources/contrastchecker/
Reviewers should focus on:
WCAG Guidelines
From what I can tell, WCAG did not require minimum contrast in 2.1, but in 2.2 has a section on focus appearance which specifies the 3:1 minimum ratio
Screenshot
Current:
![Screenshot 2024-06-21 at 8 28 04 AM](https://private-user-images.githubusercontent.com/14102129/341762353-3a52217e-de24-4f3a-9cd2-5157d583e49e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2MDcyMDMsIm5iZiI6MTcxOTYwNjkwMywicGF0aCI6Ii8xNDEwMjEyOS8zNDE3NjIzNTMtM2E1MjIxN2UtZGUyNC00ZjNhLTljZDItNTE1N2Q1ODNlNDllLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI4VDIwMzUwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM1Y2FlZTI1ZDBiYmM4MWFkMjQyOGNkYTkxZmUzMzYyZmI1MWNjMDUwNWQ4YmVmNmQ5NjczNmY4NTRhZWQ1NGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iY7uHNqKrg-f0SHpew--GNE5UQviCGLLPogn0AAi3c8)
![Screenshot 2024-06-21 at 8 27 54 AM](https://private-user-images.githubusercontent.com/14102129/341762354-ac74efeb-1a5c-440d-8b02-e30b19f4bc81.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2MDcyMDMsIm5iZiI6MTcxOTYwNjkwMywicGF0aCI6Ii8xNDEwMjEyOS8zNDE3NjIzNTQtYWM3NGVmZWItMWE1Yy00NDBkLThiMDItZTMwYjE5ZjRiYzgxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI4VDIwMzUwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRmZWNhYjBjN2VkMDA4ZjA5NmQ4ZTM0MGY4OTZjZWQ5YzE1ODViNjc1YmFjZWNmZjMyZjU3ZDE4MjFkN2QyNzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.BHGdPy55_WO8MLTFmxYM-fcUTSVndIMD8BmIPRvZRLk)
This PR:
TODO