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

fix(ui5-notification-list): improve keyboard accessibility for the "More" button #10822

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
64d24de
fix(ui5-notification-list): fix Load More button keyboard support
TeodorTaushanov Feb 11, 2025
62e10fc
Merge remote-tracking branch 'origin/main' into notifications_more_bu…
TeodorTaushanov Feb 11, 2025
e03540f
chore: handle home key
TeodorTaushanov Feb 11, 2025
eeb8a71
chore: handle up, down and end keys
TeodorTaushanov Feb 12, 2025
4142323
Merge remote-tracking branch 'origin/main' into notifications_more_bu…
TeodorTaushanov Feb 12, 2025
433ccb9
chore: improve home key handling
TeodorTaushanov Feb 12, 2025
97898c9
chore: handle whole list growing
TeodorTaushanov Feb 12, 2025
b3feb3f
Merge remote-tracking branch 'origin/main' into notifications_more_bu…
TeodorTaushanov Feb 12, 2025
4245746
chore: fix lint errors
TeodorTaushanov Feb 12, 2025
f9c3b7e
Merge remote-tracking branch 'origin/main' into notifications_more_bu…
TeodorTaushanov Feb 13, 2025
8c55a71
chore: add tests
TeodorTaushanov Feb 13, 2025
3e4269c
chore: fix menu items home/end press
TeodorTaushanov Feb 13, 2025
5e51220
chore: fix typo
TeodorTaushanov Feb 13, 2025
a9b860a
chore: handle home key on growing button
TeodorTaushanov Feb 13, 2025
4659f41
Merge remote-tracking branch 'origin/main' into notifications_more_bu…
TeodorTaushanov Feb 20, 2025
704fb70
chore: fix press space
TeodorTaushanov Feb 20, 2025
c174546
chore: fix arrow left and arrow right navigation
TeodorTaushanov Feb 20, 2025
08739e9
chore: move indication of loading to the growing button
TeodorTaushanov Feb 20, 2025
7f7c8d2
chore: add more tests
TeodorTaushanov Feb 20, 2025
ff2f450
Merge remote-tracking branch 'origin/main' into notifications_more_bu…
TeodorTaushanov Feb 20, 2025
4f74f04
chore: fix lint error
TeodorTaushanov Feb 20, 2025
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
154 changes: 154 additions & 0 deletions packages/fiori/cypress/specs/NotificationList.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import NotificationList from "../../src/NotificationList.js";
import NotificationListGroupItem from "../../src/NotificationListGroupItem.js";
import NotificationListItem from "../../src/NotificationListItem.js";

function Sample() {
return <NotificationList id="nl1">
<NotificationListGroupItem
title-text="Group 1"
id="group1"
growing="Button">
<NotificationListItem id="item11" show-close>
Group 1 Item 1
</NotificationListItem>
<NotificationListItem show-close>
Group 1 Item 2
</NotificationListItem>
<NotificationListItem show-close>
Group 1 Item 3
</NotificationListItem>
<NotificationListItem id="item1last" show-close>
Group 1 Item 4
</NotificationListItem>
</NotificationListGroupItem>
<NotificationListGroupItem
id="group2"
title-text="Group 2">
<NotificationListItem id="item21" show-close>
Group 2 Item 1
</NotificationListItem>
<NotificationListItem show-close>
Group 2 Item 2
</NotificationListItem>
<NotificationListItem show-close>
Group 2 Item 3
</NotificationListItem>
<NotificationListItem id="item2last" show-close>
Group 2 Item 4
</NotificationListItem>
</NotificationListGroupItem>
<NotificationListGroupItem
growing="Button"
title-text="Group 3">
<NotificationListItem show-close>
Group 3 Item 1
</NotificationListItem>
<NotificationListItem show-close>
Group 3 Item 2
</NotificationListItem>
<NotificationListItem show-close>
Group 3 Item 3
</NotificationListItem>
<NotificationListItem show-close>
Group 3 Item 4
</NotificationListItem>
</NotificationListGroupItem>
</NotificationList>;
}

describe("Keyboard Navigation", () => {
beforeEach(() => {
cy.mount(<Sample />);
});

it("tests Arrows and Space keys", () => {
cy.get("#group1")
.shadow()
.find("[ui5-notification-group-list]")
.shadow()
.find("[ui5-busy-indicator] .ui5-growing-button-inner")
.as("growingButton");

cy.realPress("Tab");
cy.get("#item11").realClick();
cy.get("#item11").should("be.focused");

cy.realPress("ArrowDown");
cy.realPress("ArrowDown");
cy.realPress("ArrowDown");
cy.get("#item1last").should("be.focused");

cy.realPress("ArrowDown");
cy.get("@growingButton").should("be.focused");

cy.realPress("ArrowDown");
cy.get("#group2").should("be.focused");

cy.realPress("ArrowDown");
cy.get("#item21").should("be.focused");

cy.realPress("ArrowUp");
cy.get("#group2").should("be.focused");

cy.realPress("ArrowUp");
cy.get("@growingButton").should("be.focused");

cy.realPress("ArrowUp");
cy.get("#item1last").should("be.focused");

cy.realPress("ArrowRight");
cy.get("@growingButton").should("be.focused");

cy.realPress("ArrowRight");
cy.get("#group2").should("be.focused");

cy.realPress("ArrowUp");
cy.get("@growingButton").should("be.focused");

cy.realPress("Space");
cy.get("@growingButton").should("be.focused");

cy.realPress("ArrowLeft");
cy.get("#item1last").should("be.focused");
});

it("tests Home and End", () => {
cy.get("#group1")
.shadow()
.find("[ui5-notification-group-list]")
.shadow()
.find("[ui5-busy-indicator] .ui5-growing-button-inner")
.as("growingButton");

cy.realPress("Tab");
cy.get("#item11").realClick();
cy.get("#item11").should("be.focused");

cy.realPress("End");
cy.get("#item1last").should("be.focused");

cy.realPress("End");
cy.get("@growingButton").should("be.focused");

cy.realPress("End");
cy.get("@growingButton").should("be.focused");

cy.realPress("ArrowDown");
cy.realPress("End");
cy.get("#item2last").should("be.focused");

cy.realPress("End");
cy.get("#item2last").should("be.focused");

cy.realPress("Home");
cy.realPress("ArrowUp");
cy.get("#group2").should("be.focused");

cy.realPress("ArrowUp");
cy.realPress("Home");
cy.get("#item11").should("be.focused");

cy.realPress("Home");
cy.get("#item11").should("be.focused");
});
});
8 changes: 6 additions & 2 deletions packages/fiori/src/NotificationListGroupItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ class NotificationListGroupItem extends NotificationListItemBase {
this.fireDecoratorEvent("load-more");
}

get loadMoreButton() {
getGrowingButton() {
const innerList = this.getDomRef()?.querySelector("[ui5-notification-group-list]") as NotificationListGroupList;
return innerList.getDomRef()?.querySelector(".ui5-growing-button-inner") as HTMLElement;
return innerList.getGrowingButton();
}

async _onkeydown(e: KeyboardEvent) {
Expand All @@ -225,6 +225,10 @@ class NotificationListGroupItem extends NotificationListItemBase {
return;
}

if (this.getGrowingButton()?.matches(":focus")) {
return;
}

await super._onkeydown(e);

const space = isSpace(e);
Expand Down
80 changes: 37 additions & 43 deletions packages/fiori/src/NotificationListGroupItemTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
import type NotificationListGroupItem from "./NotificationListGroupItem.js";
import Icon from "@ui5/webcomponents/dist/Icon.js";
import NotificationListGroupList from "./NotificationListGroupList.js";
Expand All @@ -22,51 +21,46 @@ export default function NotificationListItemTemplate(this: NotificationListGroup
{this.loadingText}
</span>
)}
<BusyIndicator
delay={this.loadingDelay}
active={this.loading}
inert={this.loading}
class="ui5-nli-loading"
>
<div class="ui5-nli-group-content-wrapper">
<div class="ui5-nli-group-content-wrapper">
<div
class={{
"ui5-nli-group-header": true,
"ui5-nli-group-header-expanded": this._expanded,
}}
onClick={this._onHeaderToggleClick}
onKeyDown={this._onkeydown}
role="button"
aria-expanded={this._expanded}
aria-controls={`${this._id}-notificationsList`}
title={this.toggleIconAccessibleName}>
<Icon
name={this.groupCollapsedIcon}
class="ui5-nli-group-toggle-icon"
mode="Decorative"
/>
<div
class={{
"ui5-nli-group-header": true,
"ui5-nli-group-header-expanded": this._expanded,
}}
onClick={this._onHeaderToggleClick}
onKeyDown={this._onkeydown}
role="button"
aria-expanded={this._expanded}
aria-controls={`${this._id}-notificationsList`}
title={this.toggleIconAccessibleName}>
<Icon
name={this.groupCollapsedIcon}
class="ui5-nli-group-toggle-icon"
mode="Decorative"
/>
<div
id={`${this._id}-title-text`}
class="ui5-nli-group-title-text"
part="title-text"
role="heading"
aria-level={2}
>
{this.titleText}
</div>
<div class="ui5-nli-group-divider"></div>
</div>
<NotificationListGroupList
id={`${this._id}-notificationsList`}
class="ui5-nli-group-items"
accessibleNameRef={`${this._id}-title-text`}
growing={this.growing}
onLoadMore={this._onLoadMore}
id={`${this._id}-title-text`}
class="ui5-nli-group-title-text"
part="title-text"
role="heading"
aria-level={2}
>
<slot></slot>
</NotificationListGroupList>
{this.titleText}
</div>
<div class="ui5-nli-group-divider"></div>
</div>
</BusyIndicator>
<NotificationListGroupList
id={`${this._id}-notificationsList`}
class="ui5-nli-group-items"
accessibleNameRef={`${this._id}-title-text`}
growing={this.growing}
loading={this.loading}
loadingDelay={this.loadingDelay}
onLoadMore={this._onLoadMore}
>
<slot></slot>
</NotificationListGroupList>
</div>
</li>
);
}
13 changes: 13 additions & 0 deletions packages/fiori/src/NotificationListGroupList.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import List from "@ui5/webcomponents/dist/List.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import type ListItemBase from "@ui5/webcomponents/dist/ListItemBase.js";
import { isSpace } from "@ui5/webcomponents-base/Keys.js";

/**
* @class
Expand Down Expand Up @@ -35,9 +36,21 @@ class NotificationListGroupList extends List {
e.stopImmediatePropagation();
}

_onkeydown() {

}

focusItem(item: ListItemBase) {
item.focus();
}

_onLoadMoreKeydown(e: KeyboardEvent) {
if (isSpace(e)) {
e.stopImmediatePropagation();
}

super._onLoadMoreKeydown(e);
}
}

NotificationListGroupList.define();
Expand Down
Loading