From 0238af82e7b5339d7312834e1fa788fc060cb866 Mon Sep 17 00:00:00 2001 From: Lidiya Georgieva Date: Fri, 11 Jul 2025 16:30:43 +0300 Subject: [PATCH 1/2] refactor(ui5-li-notification): change `close` event to non-bubbling fixes: #11756 --- .../fiori/cypress/specs/base/Events.cy.tsx | 79 +++++++++++++++++++ packages/fiori/src/NotificationListItem.ts | 4 +- packages/fiori/test/pages/EventBubbling.html | 46 +++++++++++ packages/main/test/pages/EventBubbling.html | 2 +- 4 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 packages/fiori/cypress/specs/base/Events.cy.tsx create mode 100644 packages/fiori/test/pages/EventBubbling.html diff --git a/packages/fiori/cypress/specs/base/Events.cy.tsx b/packages/fiori/cypress/specs/base/Events.cy.tsx new file mode 100644 index 000000000000..6f617156a50a --- /dev/null +++ b/packages/fiori/cypress/specs/base/Events.cy.tsx @@ -0,0 +1,79 @@ +import Dialog from "@ui5/webcomponents/dist/Dialog.js"; +import NotificationListItem from "../../../src/NotificationListItem.js"; +import NotificationList from "../../../src/NotificationList.js"; +import { setAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js"; +import AnimationMode from "@ui5/webcomponents-base/dist/types/AnimationMode.js"; + +describe("Event bubbling", () => { + before(() => { + cy.wrap({ setAnimationMode }) + .invoke("setAnimationMode", AnimationMode.None); + }) + + it("test bubbling events", () => { + cy.mount( +
+ + + + Office Notifications + 3 Days + + + +
+ ); + + cy.get("#app") + .as("app"); + + cy.get("[ui5-dialog]") + .as("dialog"); + + cy.get("[ui5-notification-list]") + .as("notificationList"); + + cy.get("[ui5-li-notification]") + .as("notificationListItem"); + + cy.get("@app") + .then(app => { + app.get(0).addEventListener("ui5-close", cy.stub().as("appClosed")); + }); + + cy.get("@dialog") + .then(dialog => { + dialog.get(0).addEventListener("ui5-close", cy.stub().as("dialogClosed")); + }); + + cy.get("@notificationList") + .then(notificationList => { + notificationList.get(0).addEventListener("ui5-close", cy.stub().as("notListClosed")); + }); + + cy.get("@notificationListItem") + .then(notificationListItem => { + notificationListItem.get(0).addEventListener("ui5-close", cy.stub().as("notListItemClosed")); + }); + + cy.get("@dialog").invoke("attr", "open", true); + + // act - close NotificationListItem + cy.get("@notificationListItem") + .shadow() + .find(".ui5-nli-close-btn") + .realClick(); + + // assert - the close event of the NotificationListItem does not bubble + cy.get("@notListItemClosed") + .should("have.been.calledOnce"); + cy.get("@notListClosed") + .should("have.been.not.called"); + cy.get("@dialogClosed") + .should("have.been.not.called"); + cy.get("@appClosed") + .should("have.been.not.called"); + }); +}); diff --git a/packages/fiori/src/NotificationListItem.ts b/packages/fiori/src/NotificationListItem.ts index e5cb7aa7e8fb..8a3aa6b49110 100644 --- a/packages/fiori/src/NotificationListItem.ts +++ b/packages/fiori/src/NotificationListItem.ts @@ -145,9 +145,7 @@ const ICON_PER_STATUS_DESIGN = { * @param {HTMLElement} item the closed item. * @public */ -@event("close", { - bubbles: true, -}) +@event("close") class NotificationListItem extends NotificationListItemBase { eventDetails!: NotificationListItemBase["eventDetails"] & { diff --git a/packages/fiori/test/pages/EventBubbling.html b/packages/fiori/test/pages/EventBubbling.html new file mode 100644 index 000000000000..cfbd7429e473 --- /dev/null +++ b/packages/fiori/test/pages/EventBubbling.html @@ -0,0 +1,46 @@ + + + + + + Event Bubbling for Fiori + + + + +
+ + + + Office Notifications + 3 Days + + + +
+ + + + diff --git a/packages/main/test/pages/EventBubbling.html b/packages/main/test/pages/EventBubbling.html index a477ba761484..de848662b085 100644 --- a/packages/main/test/pages/EventBubbling.html +++ b/packages/main/test/pages/EventBubbling.html @@ -3,7 +3,7 @@ - Event Bubbling + Event Bubbling for Main From 0dbb55013d785278140861b0a653c95a72870aa5 Mon Sep 17 00:00:00 2001 From: Lidiya Georgieva Date: Tue, 15 Jul 2025 16:05:01 +0300 Subject: [PATCH 2/2] chore: adding new private _close event to bubbles to the List --- packages/fiori/src/NotificationListItem.ts | 12 ++++++++++++ packages/fiori/test/pages/EventBubbling.html | 20 ++++++++++++++++---- packages/main/src/ListTemplate.tsx | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/fiori/src/NotificationListItem.ts b/packages/fiori/src/NotificationListItem.ts index 8a3aa6b49110..acd64744d1d4 100644 --- a/packages/fiori/src/NotificationListItem.ts +++ b/packages/fiori/src/NotificationListItem.ts @@ -147,10 +147,20 @@ const ICON_PER_STATUS_DESIGN = { */ @event("close") +/** + * Fired when the `Close` button is pressed. + * @param {HTMLElement} item the closed item. + * @private + */ +@event("_close", { + bubbles: true, +}) + class NotificationListItem extends NotificationListItemBase { eventDetails!: NotificationListItemBase["eventDetails"] & { _press: NotificationListItemPressEventDetail, close: NotificationListItemCloseEventDetail, + _close: NotificationListItemCloseEventDetail, } /** * Defines if the `titleText` and `description` should wrap, @@ -497,6 +507,7 @@ class NotificationListItem extends NotificationListItemBase { if (isDelete(e)) { this.fireDecoratorEvent("close", { item: this }); + this.fireDecoratorEvent("_close", { item: this }); } if (isF10Shift(e)) { @@ -510,6 +521,7 @@ class NotificationListItem extends NotificationListItemBase { _onBtnCloseClick() { this.fireDecoratorEvent("close", { item: this }); + this.fireDecoratorEvent("_close", { item: this }); } _onBtnMenuClick() { diff --git a/packages/fiori/test/pages/EventBubbling.html b/packages/fiori/test/pages/EventBubbling.html index cfbd7429e473..520bfcc6e159 100644 --- a/packages/fiori/test/pages/EventBubbling.html +++ b/packages/fiori/test/pages/EventBubbling.html @@ -24,15 +24,27 @@