Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Introducing theme variables! CSS variables beginning with `--theme-` will adjust
### Accessibility

* (breaking) Standardized interactive component states on `:focus-visible` instead of `:focus`, so the focus ring only shows for keyboard/assistive-tech focus rather than every mouse click. Affects Breadcrumb, Button, Card, Footer, Menu, Menu Item, Menu List, Modal, Navigation, Notification Bar, Sidebar Menu, and Sticky Promo. Text inputs keep `:focus` -- see the next entry.
* (breaking) Did the same in form styles for checkboxes, radio buttons, `<select>`, and the `color`/`file` input types (click/pick-driven controls, not text entry). Text-like inputs and `<textarea>` keep `:focus` -- `:focus-visible` doesn't reliably match mouse-focused text fields across engines, and losing the ring on click there would be a real accessibility regression, not an improvement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
* (breaking) Did the same in form styles for checkboxes, radio buttons, `<select>`, and the `color`/`file` input types (click/pick-driven controls, not text entry). Text-like inputs and `<textarea>` keep `:focus` -- `:focus-visible` doesn't reliably match mouse-focused text fields across engines, and losing the ring on click there would be a real accessibility regression, not an improvement.
* (breaking) Click/pick form elements now use :focus-visible but input/typing fields keep :focus.

## Component changes

### Feature Card
Expand Down
14 changes: 7 additions & 7 deletions assets/sass/protocol/base/elements/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ input[type='file'] {
border-color: var(--theme-field-border-color-hover);
}

&:focus {
&:focus-visible {
border-color: var(--theme-field-border-color-focus);
box-shadow: var(--theme-field-focus-ring);
outline: none;
Expand All @@ -272,7 +272,7 @@ input[type='file'] {
border-color: var(--theme-field-border-color-error-hover);
}

&:focus {
&:focus-visible {
border-color: var(--theme-form-red);
box-shadow: var(--theme-field-focus-ring-error);
}
Expand All @@ -284,7 +284,7 @@ input[type='file'] {
border-color: var(--theme-field-border-color-disabled);
color: var(--theme-form-text-color-inactive);

&:focus {
&:focus-visible {
border-color: var(--theme-field-border-color-disabled-focus);
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ select {
&[multiple] {
&,
&:hover,
&:focus {
&:focus-visible {
background: var(--theme-background-color);
padding: forms.$field-padding;
}
Expand All @@ -334,7 +334,7 @@ select {
background-image: $url-image-caret-down-link-hover, forms.$select-bg;
}

&:focus {
&:focus-visible {
border-color: var(--theme-field-border-color-focus);
background-image: $url-image-caret-down-link, forms.$select-bg;
box-shadow: var(--theme-field-focus-ring);
Expand All @@ -354,7 +354,7 @@ select {
border-color: var(--theme-field-border-color-error-hover);
}

&:focus {
&:focus-visible {
border-color: var(--theme-form-red);
box-shadow: var(--theme-field-focus-ring-error);
}
Expand All @@ -370,7 +370,7 @@ select {
border-color: var(--theme-field-border-color-disabled);
}

&:focus {
&:focus-visible {
border-color: var(--theme-field-border-color-disabled-focus);
}
}
Expand Down
18 changes: 9 additions & 9 deletions assets/sass/protocol/components/forms/_choice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@

// focus

&[type='checkbox']:focus + label::before,
&[type='radio']:focus + label::before {
&[type='checkbox']:focus-visible + label::before,
&[type='radio']:focus-visible + label::before {
border-color: var(--theme-field-border-color-hover);
box-shadow: var(--theme-field-focus-ring);
}

&[type='radio']:checked:focus + label::before {
&[type='radio']:checked:focus-visible + label::before {
border-color: var(--theme-field-border-color-hover);
box-shadow: inset 0 0 0 0.25em var(--theme-background-color), var(--theme-field-focus-ring);
}
Expand Down Expand Up @@ -180,13 +180,13 @@
}

// focus
&[type='checkbox']:focus + label::before,
&[type='radio']:focus + label::before {
&[type='checkbox']:focus-visible + label::before,
&[type='radio']:focus-visible + label::before {
border-color: var(--theme-field-border-color-error-hover);
box-shadow: var(--theme-field-focus-ring-error);
}

&[type='radio']:checked:focus + label::before {
&[type='radio']:checked:focus-visible + label::before {
box-shadow: inset 0 0 0 0.25em var(--theme-background-color), var(--theme-field-focus-ring-error);
}
}
Expand Down Expand Up @@ -222,13 +222,13 @@
}

// disabled focus
&[type='checkbox'][disabled]:focus + label::before,
&[type='radio'][disabled]:focus + label::before {
&[type='checkbox'][disabled]:focus-visible + label::before,
&[type='radio'][disabled]:focus-visible + label::before {
border-color: var(--theme-field-border-color-disabled);
box-shadow: var(--theme-field-focus-ring-error);
}

&[type='radio'][disabled]:checked:focus + label::before {
&[type='radio'][disabled]:checked:focus-visible + label::before {
box-shadow: inset 0 0 0 0.25em var(--theme-background-color), var(--theme-field-focus-ring);
}
}
Expand Down
25 changes: 22 additions & 3 deletions assets/sass/protocol/components/forms/_status.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@
@use '../../includes/forms';

input[list],
input[type='color'],
input[type='date'],
input[type='email'],
input[type='file'],
input[type='number'],
input[type='password'],
input[type='search'],
input[type='tel'],
input[type='text'],
input[type='time'],
input[type='url'],
select,
textarea {
.mzp-is-error & {
border-color: var(--theme-field-border-color-error);
Expand All @@ -37,3 +34,25 @@ textarea {
}
}
}

input[type='color'],
input[type='file'],
select {
.mzp-is-error & {
border-color: var(--theme-field-border-color-error);
box-shadow: none;

&:hover {
border-color: var(--theme-field-border-color-error-hover);
}

&:focus-visible {
border-color: var(--theme-field-border-color-error);
box-shadow: var(--theme-field-focus-ring-error);
}

&:focus-visible:hover {
border-color: var(--theme-field-border-color-error-hover);
}
}
}