Skip to content

Commit 4982187

Browse files
authored
refactor: accessibility (#1321)
* refactor(accessibility): axe/text-alternatives - Frames must have title attribute more information: https://dequeuniversity.com/rules/axe/4.1/frame-title * refactor(accessibility): axe/parsing - IDs used in ARIA and labels must be unique IDs used in ARIA and labels must be unique: Document has multiple elements referenced with ARIA with the same id attribute, e.g. "global" more information: https://dequeuniversity.com/rules/axe/4.1/duplicate-id-aria * refactor(accessibility): axe/name-role-value - Buttons must have discernible text: Element has no title attribute more information: https://dequeuniversity.com/rules/axe/4.1/button-name?application=axeAPI * refactor(accessibility): axe/language - added lang attribute <html> element must have a lang attribute: The <html> element does not have a lang attribute more information: https://dequeuniversity.com/rules/axe/4.2/html-has-lang * refactor(accessibility): axe/aria - ARIA attributes must conform to valid values Invalid ARIA attribute value: e.g. aria-controls="atoms" The IDs were currently missing on the related ol elements - their value (and that for variable) needs to be equal to the aria-controls-attribute on the related NavTitle tag more information: https://dequeuniversity.com/rules/axe/4.2/aria-valid-attr-value * refactor(accessibility): axe/name-role-value - Buttons must have discern… …ible text: Element has no title attribute The title-attribute needs to get transferred to the actual button itself, as this is the focusable element that even also gets recognized that read out loud by the screenreader. more information: https://dequeuniversity.com/rules/axe/4.1/button-name?application=axeAPI
1 parent 0945d64 commit 4982187

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

packages/uikit-workshop/src/html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html class="pl-c-html">
2+
<html class="pl-c-html" lang="en">
33
<head>
44
<title id="title">Pattern Lab</title>
55
<meta charset="UTF-8" />

packages/uikit-workshop/src/scripts/components/pl-nav/pl-nav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class Nav extends BaseComponent {
261261
{item.patternGroupUC}
262262
</NavTitle>
263263
<ol
264-
id={item.patternSubgroupUC}
264+
id={item.patternGroupLC}
265265
className={`pl-c-nav__sublist pl-c-nav__sublist--dropdown pl-js-acc-panel`}
266266
>
267267
{item.patternGroupItems.map((patternSubgroup, i) => {

packages/uikit-workshop/src/scripts/components/pl-nav/src/NavList.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const NavList = (props) => {
88
const { children, category, categoryName, elem } = props;
99
const reorderedChildren = [];
1010

11+
const random = Math.random().toString().substr(2);
12+
1113
const nonViewAllItems = elem.noViewAll
1214
? children.filter((item) => !item.isDocPattern)
1315
: children.filter(
@@ -33,7 +35,7 @@ export const NavList = (props) => {
3335

3436
{nonViewAllItems.length >= 1 && (
3537
<NavToggle
36-
aria-controls={category}
38+
aria-controls={`${category}-${random}`}
3739
onClick={elem.toggleSpecialNavPanel}
3840
>
3941
Expand / Collapse {category} Panel
@@ -42,15 +44,18 @@ export const NavList = (props) => {
4244
</div>
4345
))
4446
) : (
45-
<NavButton aria-controls={category} onClick={elem.toggleNavPanel}>
47+
<NavButton
48+
aria-controls={`${category}-${random}`}
49+
onClick={elem.toggleNavPanel}
50+
>
4651
{categoryName}
4752
</NavButton>
4853
)}
4954

5055
{((viewAllItems.length && nonViewAllItems.length) ||
5156
viewAllItems.length === 0) && (
5257
<ol
53-
id={category}
58+
id={`${category}-${random}`}
5459
className={`pl-c-nav__subsublist pl-c-nav__subsublist--dropdown pl-js-acc-panel`}
5560
>
5661
{nonViewAllItems.map((patternSubgroupItem) => (

packages/uikit-workshop/src/scripts/lit-components/pl-button/pl-button.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { LitElement, html } from 'lit-element';
22
import { Slotify } from '../slotify';
33
import styles from './pl-button.scss?external';
4+
import { ifDefined } from 'lit-html/directives/if-defined';
45

56
// This decorator defines the element.
67
class Button extends Slotify(LitElement) {
@@ -23,6 +24,10 @@ class Button extends Slotify(LitElement) {
2324
type: Boolean,
2425
reflect: true,
2526
},
27+
title: {
28+
attribute: true,
29+
type: String,
30+
},
2631
};
2732
}
2833

@@ -77,6 +82,7 @@ class Button extends Slotify(LitElement) {
7782
: ''}"
7883
href="${this.href}"
7984
target="${this.target ? this.target : 'self'}"
85+
title=${ifDefined(this.title === '' ? undefined : this.title)}
8086
>
8187
${this.innerTemplate()}
8288
</a>
@@ -86,6 +92,7 @@ class Button extends Slotify(LitElement) {
8692
class="pl-c-button pl-c-button--${size} ${this.iconOnly
8793
? 'pl-c-button--icon-only'
8894
: ''}"
95+
title=${ifDefined(this.title === '' ? undefined : this.title)}
8996
>
9097
${this.innerTemplate()}
9198
</button>

packages/uikit-workshop/src/scripts/lit-components/pl-tools-menu/pl-tools-menu.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class ToolsMenu extends BaseLitComponent {
128128
icon-only
129129
@click="${this.handleClick}"
130130
class="pl-c-tools__toggle"
131+
title="Settings"
131132
>
132133
<pl-icon name="settings" slot="after"></pl-icon>
133134
</pl-button>

packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ class IFrame extends BaseLitComponent {
414414
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals"
415415
src=${ifDefined(url === '' ? undefined : url)}
416416
srcdoc=${ifDefined(url === '' ? this.iframe404Fallback : undefined)}
417+
title="Pattern details"
417418
></iframe>
418419
419420
<div class="pl-c-viewport__resizer pl-js-resize-container">

0 commit comments

Comments
 (0)