Skip to content

Commit e84a3fa

Browse files
committed
feat(ui5-list): introduce accessibleName, accessibleNameRef, accessibleRole
BREAKING CHANGE: ariaLabel and ariaLabelledby are removed in favor of accessibleName and accessibleNameRef
1 parent 06f7088 commit e84a3fa

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

packages/main/src/List.js

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
66
import { getLastTabbableElement } from "@ui5/webcomponents-base/dist/util/TabbableElements.js";
77
import { isTabNext, isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
88
import NavigationMode from "@ui5/webcomponents-base/dist/types/NavigationMode.js";
9-
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
9+
import findNodeOwner from "@ui5/webcomponents-base/dist/util/findNodeOwner.js";
1010
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
1111
import debounce from "@ui5/webcomponents-base/dist/util/debounce.js";
1212
import isElementInView from "@ui5/webcomponents-base/dist/util/isElementInView.js";
@@ -185,12 +185,14 @@ const metadata = {
185185
},
186186

187187
/**
188+
* Sets the accessible aria name of the component.
189+
*
188190
* @type {String}
189191
* @defaultvalue ""
190-
* @private
191-
* @since 1.0.0-rc.8
192+
* @public
193+
* @since 1.0.0-rc.15
192194
*/
193-
ariaLabel: {
195+
accessibleName: {
194196
type: String,
195197
},
196198

@@ -199,21 +201,19 @@ const metadata = {
199201
*
200202
* @type {String}
201203
* @defaultvalue ""
202-
* @private
203-
* @since 1.0.0-rc.8
204+
* @public
205+
* @since 1.0.0-rc.15
204206
*/
205-
ariaLabelledby: {
207+
accessibleNameRef: {
206208
type: String,
207209
defaultValue: "",
208210
},
209211

210212
/**
211213
* Defines the accessible role of the component.
212214
* <br><br>
213-
* <b>Note:</b> If you use notification list items,
214-
* it's recommended to set <code>accessible-role="list"</code> for better accessibility.
215215
*
216-
* @private
216+
* @public
217217
* @type {String}
218218
* @defaultvalue "list"
219219
* @since 1.0.0-rc.15
@@ -459,6 +459,35 @@ class List extends UI5Element {
459459
}
460460
}
461461

462+
getEffectiveAriaLabelText(el) {
463+
if (!el.accessibleNameRef) {
464+
if (el.accessibleName) {
465+
return el.accessibleName;
466+
}
467+
468+
return undefined;
469+
}
470+
471+
return this.getAriaLabelledByTexts(el);
472+
};
473+
474+
getAriaLabelledByTexts(el, ownerDocument, readyIds = "") {
475+
const ids = (readyIds && readyIds.split(" ")) || el.accessibleNameRef.split(" ");
476+
const owner = ownerDocument || findNodeOwner(el);
477+
let result = "";
478+
479+
ids.forEach((elementId, index) => {
480+
const element = owner.querySelector(`[id='${elementId}']`);
481+
result += `${element ? element.textContent : ""}`;
482+
483+
if (index < ids.length - 1) {
484+
result += " ";
485+
}
486+
});
487+
488+
return result;
489+
};
490+
462491
get shouldRenderH1() {
463492
return !this.header.length && this.headerText;
464493
}
@@ -482,17 +511,17 @@ class List extends UI5Element {
482511
get isMultiSelect() {
483512
return this.mode === ListMode.MultiSelect;
484513
}
485-
514+
486515
get ariaLabelledBy() {
487-
if (this.ariaLabelledby || this.ariaLabel) {
516+
if (this.accessibleNameRef || this.accessibleName) {
488517
return undefined;
489518
}
490-
519+
491520
return this.shouldRenderH1 ? this.headerID : undefined;
492521
}
493-
522+
494523
get ariaLabelТxt() {
495-
return getEffectiveAriaLabelText(this);
524+
return this.getEffectiveAriaLabelText(this);
496525
}
497526

498527
get grows() {

packages/theme-base/css-vars-usage.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"--sapAccentColor8",
1010
"--sapAccentColor9",
1111
"--sapAccentColor10",
12-
"--sapAccentColor18",
1312
"--sapActiveColor",
1413
"--sapBackgroundColor",
1514
"--sapBlockLayer_Background",
@@ -111,6 +110,7 @@
111110
"--sapField_WarningBackground",
112111
"--sapField_WarningColor",
113112
"--sapFontFamily",
113+
"--sapFontHeader2Size",
114114
"--sapFontHeader4Size",
115115
"--sapFontHeader5Size",
116116
"--sapFontHeader6Size",
@@ -145,6 +145,7 @@
145145
"--sapLegendBackgroundColor10",
146146
"--sapLegendBackgroundColor18",
147147
"--sapLegendBackgroundColor20",
148+
"--sapLegendColor18",
148149
"--sapLink_SubtleColor",
149150
"--sapLinkColor",
150151
"--sapList_Active_Background",

0 commit comments

Comments
 (0)