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

fix(item, list): list aria roles are added #25336

Merged
merged 3 commits into from
May 23, 2022
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
4 changes: 3 additions & 1 deletion core/src/components/item/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
});
const ariaDisabled = disabled || childStyles['item-interactive-disabled'] ? 'true' : null;
const fillValue = fill || 'none';
const inList = hostContext('ion-list', this.el);
return (
<Host
aria-disabled={ariaDisabled}
Expand All @@ -402,13 +403,14 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
[`item-fill-${fillValue}`]: true,
[`item-shape-${shape}`]: shape !== undefined,
'item-disabled': disabled,
'in-list': hostContext('ion-list', this.el),
'in-list': inList,
'item-multiple-inputs': this.multipleInputs,
'ion-activatable': canActivate,
'ion-focusable': this.focusable,
'item-rtl': document.dir === 'rtl',
}),
}}
role={inList ? 'listitem' : null}
>
<TagType {...attrs} class="item-native" part="native" disabled={disabled} {...clickFn}>
<slot name="start"></slot>
Expand Down
1 change: 1 addition & 0 deletions core/src/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class List implements ComponentInterface {
const { lines, inset } = this;
return (
<Host
role="list"
class={{
[mode]: true,

Expand Down
24 changes: 24 additions & 0 deletions core/src/components/list/test/a11y/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>List - a11y</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
<script src="../../../../../scripts/testing/scripts.js"></script>
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
</head>

<body>
<main>
<h1>List - a11y</h1>
<ion-list>
<ion-item>Item 1</ion-item>
<ion-item>Item 2</ion-item>
<ion-item>Item 3</ion-item>
</ion-list>
</main>
</body>
</html>
13 changes: 13 additions & 0 deletions core/src/components/list/test/a11y/list.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import AxeBuilder from '@axe-core/playwright';
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';

test.describe('list: a11y', () => {
test('should not have accessibility violations', async ({ page }) => {
await page.goto(`/src/components/list/test/a11y`);

const results = await new AxeBuilder({ page }).analyze();

expect(results.violations).toEqual([]);
});
});