mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
fix(segment, segment-button): use correct tablist and tab roles for screen readers (#23145)
* fix(segment, segment-button): change aria attributes for segment and segment-button * add axe test * Add tests, screen reader doc * add updated screen reader * fix(segment-button): move aria tags to host * verify nvda and talkback behavior * fix(segment-button): remove outline on focus * Update core/src/components/segment/test/basic/index.html Co-authored-by: Liam DeBeasi <liamdebeasi@icloud.com>
This commit is contained in:
@ -425,6 +425,7 @@ export class Segment implements ComponentInterface {
|
||||
const mode = getIonMode(this);
|
||||
return (
|
||||
<Host
|
||||
role="tablist"
|
||||
onClick={this.onClick}
|
||||
class={createColorClasses(this.color, {
|
||||
[mode]: true,
|
||||
|
11
core/src/components/segment/test/a11y/e2e.ts
Normal file
11
core/src/components/segment/test/a11y/e2e.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { newE2EPage } from '@stencil/core/testing';
|
||||
import { AxePuppeteer } from '@axe-core/puppeteer';
|
||||
|
||||
test('segment: axe', async () => {
|
||||
const page = await newE2EPage({
|
||||
url: '/src/components/segment/test/a11y?ionic:_testing=true'
|
||||
});
|
||||
|
||||
const results = await new AxePuppeteer(page).analyze();
|
||||
expect(results.violations.length).toEqual(0);
|
||||
});
|
31
core/src/components/segment/test/a11y/index.html
Normal file
31
core/src/components/segment/test/a11y/index.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Segment - a11y</title>
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
||||
<link href="../../../../../css/core.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>Segment</h1>
|
||||
<ion-segment aria-label="Tab Options" color="dark" value="reading-list">
|
||||
<ion-segment-button value="bookmarks">
|
||||
<ion-label>Bookmarks</ion-label>
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="reading-list">
|
||||
<ion-label>Reading List</ion-label>
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="shared-links">
|
||||
<ion-label>Shared Links</ion-label>
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
24
core/src/components/segment/test/a11y/screen-readers.md
Normal file
24
core/src/components/segment/test/a11y/screen-readers.md
Normal file
@ -0,0 +1,24 @@
|
||||
"native" refers to this sample: https://w3c.github.io/aria-practices/examples/tabs/tabs-2/tabs.html
|
||||
|
||||
### Tabbing to Segment Button
|
||||
|
||||
| | native | Ionic |
|
||||
| ------------------------ | ------------------------------------------------ | ------------------------------------------------ |
|
||||
| VoiceOver macOS - Chrome | BOOKMARKS, tab, 1 of 3, Tab Options, tab group | BOOKMARKS, tab, 1 of 3, Tab Options, tab group |
|
||||
| VoiceOver macOS - Safari | BOOKMARKS, tab, 1 of 3, Tab Options, tab group | BOOKMARKS, tab, 1 of 3, Tab Options, tab group |
|
||||
| VoiceOver iOS | Bookmarks, tab | Bookmarks, tab |
|
||||
| Android TalkBack | Bookmarks, tab | Bookmarks, tab |
|
||||
| Windows NVDA | Tab Options, tab control, BOOKMARKS, tab, 1 of 3 | Tab Options, tab control, BOOKMARKS, tab, 1 of 3 |
|
||||
|
||||
### Selecting Segment Button
|
||||
|
||||
| | native | Ionic |
|
||||
| ------------------------ | -------------------------------------------------------- | ------------------------ |
|
||||
| VoiceOver macOS - Chrome | BOOKMARKS, selected, tab, 1 of 3, Tab Options, tab group | BOOKMARKS, selected, tab, 1 of 3, Tab Options, tab group |
|
||||
| VoiceOver macOS - Safari | BOOKMARKS, selected, tab, 1 of 3, Tab Options, tab group | BOOKMARKS, selected, tab, 1 of 3, Tab Options, tab group |
|
||||
| VoiceOver iOS | selected, Bookmarks, tab | selected, Bookmarks, tab |
|
||||
| Android TalkBack | selected | selected |
|
||||
| Windows NVDA | BOOKMARKS, tab, 1 of 3, selected | BOOKMARKS, tab, 1 of 3, selected |
|
||||
|
||||
Note: The `aria-label` for tablist is typically only read on the first interaction.
|
||||
|
Reference in New Issue
Block a user