-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui5-dynamic-side-content): add customizable aria labels (#10416)
Until now the **Dynamic Side Content** component (`<ui5-dynamic-side-content>`) had `role` with value **complementary** and fixed translatable `aria-label` only for its **Side Content** area. With this PR is intruduced new property `accessibilityAttributes` that can be used for setting of custom `aria-label` texts for both **Main Content** and **Side Content** areas. Also, a `role` attribute with value **main** and a fixed translatable label is provided for the **Main Content** as a fallback if there is no custom label defined. There are tests added for the new feature. Fixes: #8612
- Loading branch information
1 parent
7b9205c
commit 5887d29
Showing
6 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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,83 @@ | ||
import { html } from "lit"; | ||
import "../../src/DynamicSideContent.js"; | ||
import type DynamicSideContent from "../../src/DynamicSideContent.js"; | ||
|
||
describe("Accessibility", () => { | ||
it("tests main and side content roles", () => { | ||
cy.mount(html` | ||
<ui5-dynamic-side-content> | ||
<div> | ||
<h1>Main Content</h1> | ||
</div> | ||
<div slot="sideContent"> | ||
<h1>Side Content</h1> | ||
</div> | ||
</ui5-dynamic-side-content> | ||
`); | ||
|
||
cy.get("[ui5-dynamic-side-content]") | ||
.as("dsc"); | ||
|
||
cy.get("@dsc") | ||
.shadow() | ||
.find(".ui5-dsc-main") | ||
.should("have.attr", "role", "main"); | ||
|
||
cy.get("@dsc") | ||
.shadow() | ||
.find(".ui5-dsc-side") | ||
.should("have.attr", "role", "complementary"); | ||
}); | ||
|
||
it("tests main and side content aria-label values", () => { | ||
const customMainContentLabel = "Custom Main Content Label"; | ||
const customSideContentLabel = "Custom Side Content Label"; | ||
|
||
cy.mount(html` | ||
<ui5-dynamic-side-content> | ||
<div> | ||
<h1>Main Content</h1> | ||
<ui5-button>Set Custom ARIA Labels</ui5-button> | ||
</div> | ||
<div slot="sideContent"> | ||
<h1>Side Content</h1> | ||
</div> | ||
</ui5-dynamic-side-content> | ||
`); | ||
|
||
cy.get("[ui5-dynamic-side-content]") | ||
.as("dsc"); | ||
|
||
cy.get("@dsc") | ||
.shadow() | ||
.find(".ui5-dsc-main") | ||
.should("have.attr", "aria-label", "Main Content"); | ||
|
||
cy.get("@dsc") | ||
.shadow() | ||
.find(".ui5-dsc-side") | ||
.should("have.attr", "aria-label", "Side Content"); | ||
|
||
cy.get<DynamicSideContent>("@dsc") | ||
.then($dsc => { | ||
$dsc.get(0).accessibilityAttributes = { | ||
"mainContent": { | ||
"ariaLabel": customMainContentLabel, | ||
}, | ||
"sideContent": { | ||
"ariaLabel": customSideContentLabel, | ||
}, | ||
}; | ||
}); | ||
|
||
cy.get("@dsc") | ||
.shadow() | ||
.find(".ui5-dsc-main") | ||
.should("have.attr", "aria-label", customMainContentLabel); | ||
|
||
cy.get("@dsc") | ||
.shadow() | ||
.find(".ui5-dsc-side") | ||
.should("have.attr", "aria-label", customSideContentLabel); | ||
}); | ||
}); |
This file contains 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 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 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 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 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