Skip to content

Commit 07e8d44

Browse files
author
GerganaKremenska
authored
fix(ui5-card): allow accessibleNameRef to be used (#4118)
Previously the card did not provide a way to label the static content in the component and to be announced by screen readers and adding accessibleNameRef, solves this issue. NOTE: everything added in accessibleNameRef will be read on focusing the card Fixes: #3681
1 parent fc85924 commit 07e8d44

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

packages/main/src/Card.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const metadata = {
5050

5151
/**
5252
* Defines the accessible name of the component, which is used as the name of the card region and should be unique per card.
53-
* <b>Note:</b> <code>accessibleName</code> should be always set.
53+
* <b>Note:</b> <code>accessibleName</code> should be always set, unless <code>accessibleNameRef</code> is set.
54+
*
5455
*
5556
* @type {String}
5657
* @defaultvalue ""
@@ -60,6 +61,18 @@ const metadata = {
6061
accessibleName: {
6162
type: String,
6263
},
64+
65+
/**
66+
* Defines the IDs of the elements that label the component.
67+
*
68+
* @type {String}
69+
* @defaultvalue ""
70+
* @public
71+
* @since 1.0.0-rc.16
72+
*/
73+
accessibleNameRef: {
74+
type: String,
75+
},
6376
},
6477
events: /** @lends sap.ui.webcomponents.main.Card.prototype */ {
6578

packages/main/test/pages/Card.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@
207207
<ui5-card-header slot="header" id="header4" title-text="New Internships">
208208
</ui5-card-header>
209209
</ui5-card>
210+
211+
<ui5-card id="textCardRef" accessible-name="Internships" accessible-name-ref="cont">
212+
<ui5-card-header slot="header" id="header5" title-text="New Positions">
213+
</ui5-card-header>
214+
<div id="cont">I am the content</div>
215+
</ui5-card>
210216
<script>
211217
function onClick(event) {
212218
console.log(event);

packages/main/test/specs/Card.spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ describe("Card Accessibility", () => {
9595
const card = await browser.$("#textCard").shadow$(".ui5-card-root");
9696

9797
assert.strictEqual(await card.getAttribute("aria-label"), "Card Internships",
98-
"The aria-label is correctly when accessibleName is used.");
98+
"The aria-label is correct when accessibleName is used.");
99+
});
100+
it("test accessibleNameRef", async () => {
101+
const card = await browser.$("#textCardRef").shadow$(".ui5-card-root");
102+
103+
assert.strictEqual(await card.getAttribute("aria-label"), "Card I am the content",
104+
"The aria-label is correct when accessibleNameRef is used.");
99105
});
100106
});

0 commit comments

Comments
 (0)