-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(content): allow custom roles and aria attributes to be set on content #29753
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
6 commits
Select commit
Hold shift + click to select a range
7907a0d
fix(content): inherit attributes in content to allow custom roles
brandyscarney 70efaf0
test(content): add a11y test for roles in content
brandyscarney 534924f
test(footer): add a11y test for roles in footer
brandyscarney 1963e06
test(content): add a test for custom role in a popover
brandyscarney 623d6e6
test(header): add additional tests to a11y for roles
brandyscarney 6c3257e
test(footer): typo
brandyscarney 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { expect } from '@playwright/test'; | ||
import { configs, test } from '@utils/test/playwright'; | ||
|
||
/** | ||
* Content does not have mode-specific styling | ||
*/ | ||
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => { | ||
test.describe(title('content: a11y'), () => { | ||
test('should have the main role', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-content></ion-content> | ||
`, | ||
config | ||
); | ||
const content = page.locator('ion-content'); | ||
|
||
await expect(content).toHaveAttribute('role', 'main'); | ||
}); | ||
|
||
test('should have no role in popover', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-popover> | ||
<ion-content></ion-content> | ||
</ion-popover> | ||
`, | ||
config | ||
); | ||
|
||
const content = page.locator('ion-content'); | ||
|
||
/** | ||
* Playwright can't do .not.toHaveAttribute() because a value is expected, | ||
* and toHaveAttribute can't accept a value of type null. | ||
*/ | ||
const role = await content.getAttribute('role'); | ||
expect(role).toBeNull(); | ||
}); | ||
|
||
test('should allow for custom role', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-content role="complementary"></ion-content> | ||
`, | ||
config | ||
); | ||
const content = page.locator('ion-content'); | ||
|
||
await expect(content).toHaveAttribute('role', 'complementary'); | ||
}); | ||
|
||
test('should allow for custom role in popover', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-popover> | ||
<ion-content role="complementary"></ion-content> | ||
</ion-popover> | ||
`, | ||
config | ||
); | ||
const content = page.locator('ion-content'); | ||
|
||
await expect(content).toHaveAttribute('role', 'complementary'); | ||
}); | ||
}); | ||
}); |
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,33 @@ | ||
import { expect } from '@playwright/test'; | ||
import { configs, test } from '@utils/test/playwright'; | ||
|
||
/** | ||
* Footer does not have mode-specific styling | ||
*/ | ||
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => { | ||
test.describe(title('footer: a11y'), () => { | ||
brandyscarney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
test('should have the contentinfo role', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-footer></ion-footer> | ||
`, | ||
config | ||
); | ||
const footer = page.locator('ion-footer'); | ||
|
||
await expect(footer).toHaveAttribute('role', 'contentinfo'); | ||
}); | ||
|
||
test('should allow for custom role', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-footer role="complementary"></ion-footer> | ||
`, | ||
config | ||
); | ||
const footer = page.locator('ion-footer'); | ||
|
||
await expect(footer).toHaveAttribute('role', 'complementary'); | ||
}); | ||
}); | ||
}); |
brandyscarney marked this conversation as resolved.
Show resolved
Hide resolved
|
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.