Skip to content

Commit 99a25be

Browse files
authored
refactor(ui5-list): introduce accessibleRole prop (#3477)
Instead of creating a NotificationList web component with only role attribute changed (compared to the List), we decided to rename the List's private "accRole" property to "accessibleRole" and make it public, with default value as previous "listbox", and recommend setting it to "accessible-role=list" for the notifications use case. List: new property "accessibleRole" NotificationList(Group)Item: role="option" changed to role="listitem" to full-fill the a11y spec. Tree now setting the new prop "accessibleRole" Part of: #3107
1 parent 97a8713 commit 99a25be

8 files changed

+37
-25
lines changed

packages/fiori/src/NotificationListGroupItem.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@focusin="{{_onfocusin}}"
44
@focusout="{{_onfocusout}}"
55
@keydown="{{_onkeydown}}"
6-
role="option"
6+
role="listitem"
77
tabindex="{{_tabIndex}}"
88
dir="{{effectiveDir}}"
99
aria-expanded="{{ariaExpanded}}"
@@ -77,7 +77,7 @@
7777
<span id="{{_id}}-invisibleText" class="ui5-hidden-text">{{accInvisibleText}}</span>
7878
</div>
7979

80-
<ui5-list class="ui5-nli-group-items">
80+
<ui5-list class="ui5-nli-group-items" accessible-role="list">
8181
<slot></slot>
8282
</ui5-list>
8383

packages/fiori/src/NotificationListItem.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@keydown="{{_onkeydown}}"
66
@keyup="{{_onkeyup}}"
77
@click="{{_onclick}}"
8-
role="option"
8+
role="listitem"
99
tabindex="{{_tabIndex}}"
1010
dir="{{effectiveDir}}"
1111
aria-labelledby="{{ariaLabelledBy}}"

packages/fiori/test/pages/NotificationListGroupItem.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h3>Events on ui5-list level</h3>
4848
<li>itemToggle</li>
4949
</ul>
5050

51-
<ui5-list id="notificationList" header-text="Notifications grouped">
51+
<ui5-list id="notificationList" header-text="Notifications grouped" accessible-role="list">
5252
<ui5-li-notification-group
5353
show-close
5454
show-counter
@@ -209,7 +209,7 @@ <h3>Events on ui5-list level</h3>
209209
<ui5-toast id="wcToastBS" duration="2000"></ui5-toast>
210210

211211
<ui5-popover id="notificationsPopover" style="max-width: 400px" placement-type="Bottom" horizontal-align="Right">
212-
<ui5-list id="notificationListTop" header-text="Notifications heading and content 'truncates'">
212+
<ui5-list id="notificationListTop" header-text="Notifications heading and content 'truncates'" accessible-role="list">
213213
<ui5-li-notification-group
214214
show-close
215215
show-counter

packages/fiori/test/pages/NotificationListItem.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h3>Events on ui5-list level</h3>
4949
<li>itemClose</li>
5050
</ul>
5151

52-
<ui5-list id="notificationList" header-text="Notifications heading and content 'truncates'">
52+
<ui5-list id="notificationList" header-text="Notifications heading and content 'truncates'" accessible-role="list">
5353

5454
<ui5-li-notification
5555
busy
@@ -119,7 +119,7 @@ <h3>Events on ui5-list level</h3>
119119

120120
<br><br>
121121

122-
<ui5-list id="notificationList2" header-text="Notifications heading and content 'wraps'">
122+
<ui5-list id="notificationList2" header-text="Notifications heading and content 'wraps'" accessible-role="list">
123123

124124
<ui5-li-notification
125125
show-close
@@ -172,7 +172,7 @@ <h3>Events on ui5-list level</h3>
172172
<ui5-toast id="wcToastBS" duration="2000"></ui5-toast>
173173

174174
<ui5-popover id="notificationsPopover" style="max-width: 400px" placement-type="Bottom" horizontal-align="Right">
175-
<ui5-list id="notificationListTop" header-text="Notifications heading and content 'truncates'">
175+
<ui5-list id="notificationListTop" header-text="Notifications heading and content 'truncates'" accessible-role="list">
176176
<ui5-li-notification
177177
show-close
178178
heading="New order (#2525) With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc."

packages/fiori/test/specs/NotificationList.spec.js

+20-11
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,7 @@ describe("Notification List Item Tests", () => {
158158
"The ariaLabelledBy text is correct.");
159159
});
160160

161-
it("tests List Item ACC invisible text", () => {
162-
const EXPECTED_RESULT = "Notification unread High Priority";
163-
const firstItem = $("#nli1");
164-
const invisibleText = firstItem.shadow$(".ui5-hidden-text");
165-
166-
// assert
167-
assert.strictEqual(invisibleText.getText().toLowerCase(), EXPECTED_RESULT.toLowerCase(),
168-
"The invisible text is correct.");
169-
});
170-
171-
it("tests List Group Item ACC ariaLabelledBy", () => {
161+
it("tests List Item ACC ariaLabelledBy", () => {
172162
const firstItem = $("#nli1");
173163
const firstItemRoot = firstItem.shadow$(".ui5-nli-root");
174164

@@ -182,4 +172,23 @@ describe("Notification List Item Tests", () => {
182172
assert.strictEqual(firstItemRoot.getAttribute("aria-labelledby"), EXPECTED_ARIA_LABELLED_BY,
183173
"The ariaLabelledBy text is correct.");
184174
});
175+
176+
it("tests List Item ACC invisible text", () => {
177+
const EXPECTED_RESULT = "Notification unread High Priority";
178+
const firstItem = $("#nli1");
179+
const invisibleText = firstItem.shadow$(".ui5-hidden-text");
180+
181+
// assert
182+
assert.strictEqual(invisibleText.getText().toLowerCase(), EXPECTED_RESULT.toLowerCase(),
183+
"The invisible text is correct.");
184+
});
185+
186+
it("tests List (Group) Item ACC role", () => {
187+
const firstItemRoot = $("#nli1").shadow$(".ui5-nli-root");
188+
const firstGroupItemRoot = $("#nlgi1").shadow$(".ui5-nli-group-root");
189+
const EXPECTED_ROLE = "listitem";
190+
191+
assert.strictEqual(firstGroupItemRoot.getAttribute("role"), EXPECTED_ROLE, "The role text is correct.");
192+
assert.strictEqual(firstItemRoot.getAttribute("role"), EXPECTED_ROLE, "The role text is correct.");
193+
});
185194
});

packages/main/src/List.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<ul id="{{_id}}-listUl"
2222
class="ui5-list-ul"
23-
role="{{accRole}}"
23+
role="{{accessibleRole}}"
2424
aria-label="{{ariaLabelТxt}}"
2525
aria-labelledby="{{ariaLabelledBy}}"
2626
aria-multiselectable="{{isMultiSelect}}"

packages/main/src/List.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,17 @@ const metadata = {
222222
},
223223

224224
/**
225-
* Used to externally manipulate the role of the list
225+
* Defines the accessible role of the component.
226+
* <br><br>
227+
* <b>Note:</b> If you use notification list items,
228+
* it's recommended to set <code>accessible-role="list"</code> for better accessibility.
226229
*
227-
* @private
230+
* @public
228231
* @type {String}
229232
* @defaultvalue "listbox"
230-
* @since 1.0.0-rc.9
233+
* @since 1.0.0-rc.15
231234
*/
232-
accRole: {
235+
accessibleRole: {
233236
type: String,
234237
defaultValue: "listbox",
235238
},

packages/main/src/Tree.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.headerText="{{headerText}}"
44
.footerText="{{footerText}}"
55
.noDataText="{{noDataText}}"
6-
.accRole="{{_role}}"
6+
.accessibleRole="{{_role}}"
77
@ui5-item-click="{{_onListItemClick}}"
88
@ui5-item-delete="{{_onListItemDelete}}"
99
@ui5-selection-change="{{_onListSelectionChange}}"

0 commit comments

Comments
 (0)