Skip to content

Commit

Permalink
fix(ui5-side-navigation-item): click event is no longer fired twice (#…
Browse files Browse the repository at this point in the history
…8958)

Fixes: #8692
  • Loading branch information
dimovpetar authored May 14, 2024
1 parent 30a40e3 commit f3e2d88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
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" title="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" title="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 @@ -226,9 +226,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

0 comments on commit f3e2d88

Please sign in to comment.