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

Improve a11y of form error state v2 #2090

Merged
merged 19 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"path": "./dist/css/boosted-reboot.css",
"maxSize": "4.25 kB"
"maxSize": "4.5 kB"
},
{
"path": "./dist/css/boosted-reboot.min.css",
Expand Down
10 changes: 6 additions & 4 deletions scss/_reboot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,23 @@ body {
// 1. Default focus state
// 2. Using the :focus-visible polyfill to hide outline defensively
// See https://github.com/WICG/focus-visible
// Note: this rule is not applied for our focus ring helper which
// Note 1: this rule is not applied for our focus ring helper which
// handles itself outline and box shadow
// Note 2: this rule is also not applied for invalid select and invalid input files to ensure
// sufficient contrast between select elements on error focused vs. non focused
// 3. Using the :focus-visible pseudo-class if supported by the browser
// scss-docs-start focus-visibility
:focus {
@include focus-visible(); // 1
}

.js-focus-visible :focus:not([data-focus-visible-added]):not(.focus-ring),
.js-focus-visible .focus:not([data-focus-visible-added]):not(.focus-ring) { // 2
.js-focus-visible :focus:not([data-focus-visible-added]):not(.focus-ring):not(.form-select:invalid):not(.form-control[type="file"]:invalid),
.js-focus-visible .focus:not([data-focus-visible-added]):not(.focus-ring):not(.form-select:invalid):not(.form-control[type="file"]:invalid) { // 2
outline: 0 !important;
box-shadow: none;
}

:focus:not(:focus-visible):not(.focus-ring) { // 3
:focus:not(:focus-visible):not(.focus-ring):not(.form-select:invalid):not(.form-control[type="file"]:invalid) { // 3
outline: 0 !important;
box-shadow: none;
}
Expand Down
14 changes: 14 additions & 0 deletions scss/mixins/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@
// Boosted mod: no box-shadow

// Boosted mod: focus styles don't match validation state

// Boosted mod: apply focus mixin to allow sufficient contrast between error field focused and non focused
&:focus {
@include focus-visible();
border-color: $border-color !important; // stylelint-disable-line declaration-no-important
}
// End mod
}
}

Expand Down Expand Up @@ -123,6 +130,13 @@
// Boosted mod: no box-shadow

// Boosted mod: focus styles don't match validation state

// Boosted mod: apply focus mixin to allow sufficient contrast between error field focused and non focused
&:focus {
@include focus-visible();
border-color: $border-color !important; // stylelint-disable-line declaration-no-important
}
// End mod
}
}

Expand Down
6 changes: 5 additions & 1 deletion site/content/docs/5.3/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ If you need more details about the changes, please refer to the [v5.3.2 release]
- **Orange navbar**
- <span class="badge bg-warning">Warning</span> The minimizing behavior with `.header-minimized` is applied to the `<header>` instead of one of its children directly.

### Forms

- <span class="badge bg-success">New</span> In order to improve accessibility for people suffering from any form of color blindness, we added a visual cue to form elements on error when focused so information does not rely exclusively on color anymore. Although is has no direct impact, you might want to apply this same modification within your custom form controls if you have any.

## v5.3.1

<hr class="mb-4">
Expand Down Expand Up @@ -1025,7 +1029,7 @@ If you need more details about the changes, please refer to the [v5.2.1 release]
{{< /markdown >}}
</details>

- The close icon SVG rendering has changed in modals, offcanvases and close buttons. Although is has no direct impact, you might want apply this same modification within your websites.
- The close icon SVG rendering has changed in modals, offcanvases and close buttons. Although is has no direct impact, you might want to apply this same modification within your websites.

### Helpers and utilities

Expand Down