-
Notifications
You must be signed in to change notification settings - Fork 13.5k
fix(menu): improve menu accessibility #24076
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
579e710
fix(menu): add basic accessibility features
e51440b
fix(menu): add focus trapping
1ab27f0
test(menu): add test for focus trapping
2fef453
style(menu): lint fixes
56e1e44
fix(menu): focus first element inside instead of whole menu
a4cda65
test(menu): fix focus trap test to account for new behavior
bdc3201
refactor(menu): pull focus handler into its own prop
e23f5f3
test(menu): add a11y testing
51d32ac
fix(menu): prevent nested aria landmark from header inside menu
052ac2e
fix(menu): revert switch to nav element
150a7ac
fix(menu): remove unnecessary import from test
079b62f
fix(menu): allow for custom aria-label
f071d7d
fix(menu): move nested ARIA role logic to header for flexibility
045afe5
fix(item): only add focusable class if it actually is focusable
c30239a
fix(menu): allow focusing of menu itself, for a11y on menus with no f…
ede41b0
fix(item): move isFocusable logic to state for better reactivity
c334776
perf(item): only grab one focusable child
9066592
fix(menu): hide page content from screen readers when menu is open
3ba672a
fix(menu): fallback to focusing host element
liamdebeasi 5782e26
docs(menu): add comments
liamdebeasi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { newE2EPage } from '@stencil/core/testing'; | ||
import { AxePuppeteer } from '@axe-core/puppeteer'; | ||
|
||
test('menu: axe', async () => { | ||
const page = await newE2EPage({ | ||
url: '/src/components/menu/test/a11y?ionic:_testing=true' | ||
}); | ||
|
||
const menu = await page.find('ion-menu'); | ||
await menu.callMethod('open'); | ||
await menu.waitForVisible(); | ||
|
||
const results = await new AxePuppeteer(page).analyze(); | ||
expect(results.violations.length).toEqual(0); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!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>Menu</h1> | ||
<ion-menu menu-id="menu" content-id="main-content"> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>Menu</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content> | ||
<ion-list> | ||
<ion-item> | ||
<ion-button>Button</ion-button> | ||
</ion-item> | ||
<ion-item> | ||
<ion-button>Button 2</ion-button> | ||
</ion-item> | ||
<ion-item>Menu Item</ion-item> | ||
<ion-item>Menu Item</ion-item> | ||
<ion-item>Menu Item</ion-item> | ||
</ion-list> | ||
</ion-content> | ||
</ion-menu> | ||
</main> | ||
</body> | ||
|
||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.