Skip to content

Commit 882ed66

Browse files
Wagner3UBwesleybl
andauthored
fix: add consistent visible focus for interactive components (a11y) - backport v19 (#8381)
Co-authored-by: Wesley Barroso Lopes <wesleybl@gmail.com>
1 parent 74d82ed commit 882ed66

6 files changed

Lines changed: 43 additions & 3 deletions

File tree

packages/volto/cypress/tests/core/blocks/blocks-image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Blocks Tests', () => {
2929
cy.get('.block-editor-image [tabindex="0"]')
3030
.last()
3131
.focus()
32-
.should('have.css', 'outline', 'rgb(16, 16, 16) auto 1px');
32+
.should('have.css', 'outline', 'rgb(0, 0, 0) solid 2px');
3333
cy.findByLabelText('Enter a URL to an image').click();
3434
cy.get('.ui.input.editor-link.input-anchorlink-theme input').type(
3535
`https://github.com/plone/volto/raw/main/logos/volto-colorful.png{enter}`,

packages/volto/news/8381.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added consistent visible focus for interactive components to improve accessibility. @Wagner3UB
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.universal-focus-style() {
2+
box-shadow: 0 0 0 2px @innerFocusShadow !important;
3+
outline: 2px solid @outerFocusOutline !important;
4+
outline-offset: 2px;
5+
}
6+
7+
// Global focus styles for all elements that support :focus-visible
8+
// Exclude contenteditable elements (slate editors, rich text inputs) — focus is
9+
// already implied by the text cursor; an outline ring is noisy and confusing.
10+
:focus-visible:not([contenteditable]):not([data-slate-editor]) {
11+
.universal-focus-style();
12+
}
13+
14+
//inputs modifications
15+
input:focus-visible {
16+
border-color: @outerFocusOutline !important;
17+
}
18+
19+
// Semantic UI checkbox focus styles
20+
.ui.checkbox input:focus-visible ~ label::before {
21+
.universal-focus-style();
22+
outline-offset: 4px;
23+
}
24+
25+
.ui.checkbox input:focus-visible ~ label::before {
26+
transition: none !important;
27+
}
28+
29+
// Skiplinks focus styles
30+
.skiplinks-wrapper a:focus-visible {
31+
border: 2px solid @linkColor;
32+
outline: 3px solid @linkColor;
33+
}

packages/volto/theme/themes/pastanaga/extras/main.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,4 +699,5 @@ img.responsive {
699699
@import 'views';
700700
@import 'toc';
701701
@import 'grid.less';
702+
@import 'focus.less';
702703
.loadUIOverrides();

packages/volto/theme/themes/pastanaga/extras/skiplinks.less

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
top: 10px;
1313
left: 10px;
1414
padding: 10px;
15-
border: 2px solid @linkColor;
1615
background: #fff;
17-
outline: 3px solid @linkColor;
1816
}
1917

2018
&:hover {

packages/volto/theme/themes/pastanaga/globals/site.variables

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,10 @@
363363
/*--- Dark Tones ---*/
364364

365365
/*--- Light Tones ---*/
366+
367+
/*-------------------
368+
Focused Input
369+
--------------------*/
370+
371+
@innerFocusShadow: #fff;
372+
@outerFocusOutline: #000;

0 commit comments

Comments
 (0)