Skip to content

Commit

Permalink
feat(forms): add a visual cue to form elements on error when focused …
Browse files Browse the repository at this point in the history
…for a11y (#2090)

Co-authored-by: Julien Déramond <julien.deramond@orange.com>
  • Loading branch information
MewenLeHo and julien-deramond authored Jul 28, 2023
1 parent f907f4c commit 17f6f4d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
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

0 comments on commit 17f6f4d

Please sign in to comment.