Skip to content
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

feat(ui5-li-notification*): full-fill accessibility spec #2578

Merged
merged 2 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/fiori/src/NotificationListGroupItem.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
role="option"
tabindex="{{_tabIndex}}"
dir="{{effectiveDir}}"
aria-expanded="{{ariaExpanded}}"
aria-labelledby="{{ariaLabelledBy}}"
style="list-style-type: none;"
>
Expand All @@ -15,6 +16,8 @@
design="Transparent"
@click="{{_onBtnToggleClick}}"
class="ui5-nli-group-toggle-btn"
title="{{toggleBtnAccessibleName}}"
aria-label="{{toggleBtnAccessibleName}}"
></ui5-button>

{{#if hasPriority}}
Expand All @@ -41,7 +44,8 @@
design="Transparent"
@click="{{_onBtnOverflowClick}}"
class="ui5-nli-overflow-btn"
title="{{overflowBtnTitle}}"
title="{{overflowBtnAccessibleName}}"
aria-label="{{overflowBtnAccessibleName}}"
></ui5-button>
{{else}}
{{#each standardActions}}
Expand All @@ -64,7 +68,8 @@
icon="decline"
design="Transparent"
@click="{{_onBtnCloseClick}}"
title="{{closeBtnTitle}}"
title="{{closeBtnAccessibleName}}"
aria-label="{{closeBtnAccessibleName}}"
close-btn
></ui5-button>
{{/if}}
Expand Down
46 changes: 37 additions & 9 deletions packages/fiori/src/NotificationListGroupItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import NotificationListItemBase from "./NotificationListItemBase.js";
import {
NOTIFICATION_LIST_GROUP_ITEM_TXT,
NOTIFICATION_LIST_GROUP_ITEM_COUNTER_TXT,
NOTIFICATION_LIST_ITEM_READ,
NOTIFICATION_LIST_ITEM_UNREAD,
NOTIFICATION_LIST_ITEM_HIGH_PRIORITY_TXT,
NOTIFICATION_LIST_ITEM_MEDIUM_PRIORITY_TXT,
NOTIFICATION_LIST_ITEM_LOW_PRIORITY_TXT,
NOTIFICATION_LIST_ITEM_OVERLOW_BTN_TITLE,
NOTIFICATION_LIST_ITEM_CLOSE_BTN_TITLE,
NOTIFICATION_LIST_GROUP_ITEM_CLOSE_BTN_TITLE,
NOTIFICATION_LIST_GROUP_ITEM_TOGGLE_BTN_COLLAPSE_TITLE,
NOTIFICATION_LIST_GROUP_ITEM_TOGGLE_BTN_EXPAND_TITLE,
} from "./generated/i18n/i18n-defaults.js";

// Templates
Expand Down Expand Up @@ -161,12 +165,20 @@ class NotificationListGroupItem extends NotificationListItemBase {
return this.items.length;
}

get overflowBtnTitle() {
get overflowBtnAccessibleName() {
return this.i18nBundle.getText(NOTIFICATION_LIST_ITEM_OVERLOW_BTN_TITLE);
}

get closeBtnTitle() {
return this.i18nBundle.getText(NOTIFICATION_LIST_ITEM_CLOSE_BTN_TITLE);
get closeBtnAccessibleName() {
return this.i18nBundle.getText(NOTIFICATION_LIST_GROUP_ITEM_CLOSE_BTN_TITLE);
}

get toggleBtnAccessibleName() {
if (this.collapsed) {
return this.i18nBundle.getText(NOTIFICATION_LIST_GROUP_ITEM_TOGGLE_BTN_EXPAND_TITLE);
}

return this.i18nBundle.getText(NOTIFICATION_LIST_GROUP_ITEM_TOGGLE_BTN_COLLAPSE_TITLE);
}

get priorityText() {
Expand All @@ -186,12 +198,24 @@ class NotificationListGroupItem extends NotificationListItemBase {
}

get accInvisibleText() {
const groupTxt = this.i18nBundle.getText(NOTIFICATION_LIST_GROUP_ITEM_TXT);
const counterTxt = this.i18nBundle.getText(NOTIFICATION_LIST_GROUP_ITEM_COUNTER_TXT);
const counter = this.showCounter ? `${counterTxt} ${this.itemsCount}` : "";
const priorityText = this.priorityText;
return `${this.groupText} ${this.readText} ${this.priorityText} ${this.counterText}`;
}

get readText() {
if (this.read) {
return this.i18nBundle.getText(NOTIFICATION_LIST_ITEM_READ);
}

return `${groupTxt} ${priorityText} ${counter}`;
return this.i18nBundle.getText(NOTIFICATION_LIST_ITEM_UNREAD);
}

get groupText() {
return this.i18nBundle.getText(NOTIFICATION_LIST_GROUP_ITEM_TXT);
}

get counterText() {
const text = this.i18nBundle.getText(NOTIFICATION_LIST_GROUP_ITEM_COUNTER_TXT);
return this.showCounter ? `${text} ${this.itemsCount}` : "";
}

get ariaLabelledBy() {
Expand All @@ -207,6 +231,10 @@ class NotificationListGroupItem extends NotificationListItemBase {
return ids.join(" ");
}

get ariaExpanded() {
return !this.collapsed;
}

/**
* Event handlers
*
Expand Down
8 changes: 5 additions & 3 deletions packages/fiori/src/NotificationListItem.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
design="Transparent"
@click="{{_onBtnOverflowClick}}"
class="ui5-nli-overflow-btn"
title="{{overflowBtnTitle}}"
title="{{overflowBtnAccessibleName}}"
aria-label="{{overflowBtnAccessibleName}}"
></ui5-button>
{{else}}
{{#each standardActions}}
Expand All @@ -40,7 +41,8 @@
icon="decline"
design="Transparent"
@click="{{_onBtnCloseClick}}"
title="{{closeBtnTitle}}"
title="{{closeBtnAccessibleName}}"
aria-label="{{closeBtnAccessibleName}}"
close-btn
></ui5-button>
{{/if}}
Expand All @@ -55,7 +57,7 @@
</ui5-icon>
{{/if}}

<div id="{{_id}}-heading" class="ui5-nli-title" part="heading">
<div id="{{_id}}-heading" class="ui5-nli-heading" part="heading">
{{heading}}
</div>
</div>
Expand Down
19 changes: 3 additions & 16 deletions packages/fiori/src/NotificationListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,6 @@ const metadata = {
type: Boolean,
},

/**
* Defines if the <code>notification</code> is new or has been already read.
* <br><br>
* <b>Note:</b> if set to <code>false</code> the <code>heading</code> has bold font,
* if set to true - it has a normal font.
* @type {boolean}
* @defaultvalue false
* @public
*/
read: {
type: Boolean,
},

/**
* Defines the state of the <code>heading</code> and <code>description</code>,
* if less or more information is displayed.
Expand Down Expand Up @@ -236,11 +223,11 @@ class NotificationListItem extends NotificationListItemBase {
return this.i18nBundle.getText(NOTIFICATION_LIST_ITEM_SHOW_MORE);
}

get overflowBtnTitle() {
get overflowBtnAccessibleName() {
return this.i18nBundle.getText(NOTIFICATION_LIST_ITEM_OVERLOW_BTN_TITLE);
}

get closeBtnTitle() {
get closeBtnAccessibleName() {
return this.i18nBundle.getText(NOTIFICATION_LIST_ITEM_CLOSE_BTN_TITLE);
}

Expand All @@ -257,7 +244,7 @@ class NotificationListItem extends NotificationListItemBase {
}

get headingDOM() {
return this.shadowRoot.querySelector(".ui5-nli-title");
return this.shadowRoot.querySelector(".ui5-nli-heading");
}

get headingHeight() {
Expand Down
13 changes: 13 additions & 0 deletions packages/fiori/src/NotificationListItemBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ const metadata = {
type: Boolean,
},

/**
* Defines if the <code>notification</code> is new or has been already read.
* <br><br>
* <b>Note:</b> if set to <code>false</code> the <code>heading</code> has bold font,
* if set to true - it has a normal font.
* @type {boolean}
* @defaultvalue false
* @public
*/
read: {
type: Boolean,
},

/**
* Defines if a busy indicator would be displayed over the item.
* @type {boolean}
Expand Down
9 changes: 9 additions & 0 deletions packages/fiori/src/i18n/messagebundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ NOTIFICATION_LIST_GROUP_ITEM_TXT=Notification group
#XTXT: Text for the NotificationListGroupItem counter
NOTIFICATION_LIST_GROUP_ITEM_COUNTER_TXT=Counter

#XBUT: accessible name for 'Close All' button in the NotificationListGroupItem
NOTIFICATION_LIST_GROUP_ITEM_CLOSE_BTN_TITLE=Close All

#XBUT: accessible name for 'Toggle' button in the NotificationListGroupItem
NOTIFICATION_LIST_GROUP_ITEM_TOGGLE_BTN_COLLAPSE_TITLE=Collapse Group

#XBUT: accessible name for 'Toggle' button in the NotificationListGroupItem
NOTIFICATION_LIST_GROUP_ITEM_TOGGLE_BTN_EXPAND_TITLE=Expand Group

#XACT: ARIA announcement for timeline label
TIMELINE_ARIA_LABEL=Timeline

Expand Down
5 changes: 5 additions & 0 deletions packages/fiori/src/themes/NotificationListGroupItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
display: none;
}

:host([read]) .ui5-nli-group-heading {
font-weight: normal;
}

.ui5-nli-group-root {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -36,6 +40,7 @@
color: var(--sapGroup_TitleTextColor);
font-family: "72override", var(--sapFontFamily);
font-size: var(--sapFontHeader6Size);
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
Expand Down
12 changes: 6 additions & 6 deletions packages/fiori/src/themes/NotificationListItem.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "./NotificationListItemBase.css";
@import "./NotificationPrioIcon.css";

:host(:not([wrap])) .ui5-nli-title {
:host(:not([wrap])) .ui5-nli-heading {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
Expand All @@ -15,15 +15,15 @@
overflow: hidden;
}

:host([_show-more-pressed]) .ui5-nli-title {
:host([_show-more-pressed]) .ui5-nli-heading {
-webkit-line-clamp: unset;
}

:host([_show-more-pressed]) .ui5-nli-description {
-webkit-line-clamp: unset;
}

:host([read]) .ui5-nli-title {
:host([read]) .ui5-nli-heading {
font-weight: normal;
}

Expand All @@ -32,11 +32,11 @@
max-height: 32px;
}

:host(:not([wrap])) .ui5-nli-content--ie .ui5-nli-title {
:host(:not([wrap])) .ui5-nli-content--ie .ui5-nli-heading {
max-height: 32px;
}

:host([_show-more-pressed]) .ui5-nli-content--ie .ui5-nli-title {
:host([_show-more-pressed]) .ui5-nli-content--ie .ui5-nli-heading {
max-height: inherit;
}

Expand Down Expand Up @@ -71,7 +71,7 @@
box-sizing: border-box;
}

.ui5-nli-title {
.ui5-nli-heading {
color: var(--sapGroup_TitleTextColor);
font-weight: bold;
font-size: var(--sapFontHeader6Size);
Expand Down
2 changes: 2 additions & 0 deletions packages/fiori/test/pages/NotificationListGroupItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h3>Properties</h3>
<li>collapsed (default: "false")</li>
<li>show-close (default: "false")</li>
<li>show-counter (default: "false")</li>
<li>read (default: "false")</li>
</ul>

<h3>Slots</h3>
Expand Down Expand Up @@ -155,6 +156,7 @@ <h3>Events on ui5-list level</h3>
id="busyGroup"
show-close
show-counter
read
priority="High"
heading="Meetings 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."
>
Expand Down
25 changes: 24 additions & 1 deletion packages/fiori/test/specs/NotificationList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("Notification List Item Tests", () => {
});

it("tests List Group Item ACC invisible text", () => {
const EXPECTED_RESULT = "Notification group High Priority Counter 2";
const EXPECTED_RESULT = "Notification group unread High Priority Counter 2";
const firstGroupItem = $("#nlgi1");
const invisibleText = firstGroupItem.shadow$(".ui5-hidden-text");

Expand All @@ -122,6 +122,29 @@ describe("Notification List Item Tests", () => {
"The invisible text is correct.");
});

it("tests List Group Item aria-expanded aria-label when collapsed and expanded", () => {
const groupItem = browser.$("#nlgi3");
const goupItemRoot = groupItem.shadow$(".ui5-nli-group-root");
const goupItemToggleBtn = groupItem.shadow$(".ui5-nli-group-toggle-btn");
const TOGGLE_BUTTON_EXPAND_GROUP = "Expand Group";
const TOGGLE_BUTTON_COLLAPSE_GROUP = "Collapse Group";

// assert
assert.strictEqual(goupItemRoot.getAttribute("aria-expanded"), "false",
"The aria-expanded value is correct.");
assert.strictEqual(goupItemToggleBtn.getAttribute("aria-label"), TOGGLE_BUTTON_EXPAND_GROUP,
"The aria-label value is correct.");

// act
goupItemToggleBtn.click();

// assert
assert.strictEqual(goupItemRoot.getAttribute("aria-expanded"), "true",
"The aria-expanded value is correct.");
assert.strictEqual(goupItemToggleBtn.getAttribute("aria-label"), TOGGLE_BUTTON_COLLAPSE_GROUP,
"The aria-label value is correct.");
});

it("tests List Group Item ACC ariaLabelledBy", () => {
const firstGroupItem = $("#nlgi1");
const firstGroupItemRoot = firstGroupItem.shadow$(".ui5-nli-group-root");
Expand Down