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-side-navigation-item): click event is no longer fired twice #8944

Merged
merged 1 commit into from
May 14, 2024
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
2 changes: 2 additions & 0 deletions packages/fiori/src/SideNavigationSelectableItemBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class SideNavigationSelectableItemBase extends SideNavigationItemBase {
}

_activate(e: KeyboardEvent | PointerEvent) {
e.stopPropagation();

if (this.isOverflow) {
this.fireEvent("click");
} else {
Expand Down
7 changes: 6 additions & 1 deletion packages/fiori/test/pages/SideNavigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<ui5-side-navigation-sub-item text="Others"></ui5-side-navigation-sub-item>
</ui5-side-navigation-item>
<ui5-side-navigation-item disabled id="item1" text="Home" icon="home" tooltip="Home tooltip"></ui5-side-navigation-item>
<ui5-side-navigation-item id="toggle" text="Toggle" icon="menu"></ui5-side-navigation-item>

<!-- Fixed Items -->
<ui5-side-navigation-item id="fixedItem1" slot="fixedItems" text="Useful Links" icon="chain-link" tooltip="Useful links tooltip">
Expand Down Expand Up @@ -96,8 +97,12 @@
sideNavigation.collapsed = !sideNavigation.collapsed;
});

document.getElementById("toggle").addEventListener("click", () => {
sideNavigation.collapsed = !sideNavigation.collapsed;
});

document.querySelectorAll("ui5-side-navigation-item").forEach(function (item) {
item.addEventListener("ui5-click", function (event) {
item.addEventListener("click", function (event) {
clickInput.value = ++clickCounter;
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/fiori/test/specs/SideNavigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ describe("Component Behavior", () => {

// fixed items
assert.strictEqual(await sideNavigationFixedTree.getAttribute("aria-roledescription"), roleDescription, "Role description of the SideNavigation fixed tree element is correctly set");
assert.notExists(await items[8].getAttribute("aria-roledescription"), "Role description of the SideNavigation fixed tree item is not set");
assert.strictEqual(await items[8].getAttribute("aria-haspopup"), "tree", "There is 'aria-haspopup' with correct value");
assert.notExists(await items[9].getAttribute("aria-haspopup"), "There is no 'aria-haspopup'");
assert.notExists(await items[9].getAttribute("aria-roledescription"), "Role description of the SideNavigation fixed tree item is not set");
assert.strictEqual(await items[9].getAttribute("aria-haspopup"), "tree", "There is 'aria-haspopup' with correct value");
assert.notExists(await items[10].getAttribute("aria-haspopup"), "There is no 'aria-haspopup'");

// popup
await browser.$("#item2").click();
Expand Down