Skip to content

Commit 5bbb264

Browse files
fix(ui5-shellbar): ensure avatar click event is triggered correctly (#12055)
Fixes: #11920
1 parent 7569ed8 commit 5bbb264

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

packages/fiori/cypress/specs/ShellBar.cy.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,37 @@ describe("Responsiveness", () => {
321321
});
322322

323323
describe("Slots", () => {
324+
describe("Profile slot", () => {
325+
it("forwards click from shellbar profile button to slotted avatar (mount pattern)", () => {
326+
const clickSpy = cy.spy().as("avatarClickSpy");
327+
const profileClickSpy = cy.spy().as("profileClickSpy");
328+
329+
cy.mount(
330+
<div>
331+
<ShellBar id="test-shellbar">
332+
<Avatar
333+
id="test-avatar"
334+
slot="profile"
335+
interactive
336+
initials="XY"
337+
/>
338+
</ShellBar>
339+
</div>
340+
);
341+
342+
cy.get("#test-avatar").then($el => {
343+
$el[0].addEventListener("ui5-click", clickSpy);
344+
});
345+
cy.get("#test-shellbar").then($el => {
346+
$el[0].addEventListener("ui5-profile-click", profileClickSpy);
347+
});
348+
349+
cy.get("#test-shellbar").shadow().find(".ui5-shellbar-image-button").realClick();
350+
cy.get("@profileClickSpy").should("have.been.calledOnce");
351+
cy.get("@avatarClickSpy").should("have.been.calledOnce");
352+
});
353+
});
354+
324355
describe("Content slot", () => {
325356
it("Test separators visibility", () => {
326357
function assertStartSeparatorVisibility(expectedExist: boolean) {
@@ -763,7 +794,7 @@ describe("Events", () => {
763794
cy.get("@shellbar")
764795
.shadow()
765796
.find("[data-profile-btn]")
766-
.click();
797+
.click({ force: true });
767798

768799
cy.get("@profileClick")
769800
.should("have.been.calledOnce");
@@ -985,7 +1016,7 @@ describe("Events", () => {
9851016
cy.get("@shellbar")
9861017
.shadow()
9871018
.find("[data-profile-btn]")
988-
.click();
1019+
.click({ force: true });
9891020

9901021
cy.get("@profileClick")
9911022
.should("have.been.calledOnce");

packages/fiori/src/themes/ShellBar.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ slot[name="profile"] {
114114
height: 2rem;
115115
min-width: 0;
116116
min-height: 2rem;
117-
pointer-events: none;
118117
font-size: var(--_ui5_avatar_fontsize_XS);
119118
font-weight: normal;
120119
}

packages/main/src/themes/Button.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
content: "";
118118
position: absolute;
119119
box-sizing: border-box;
120+
pointer-events: none;
120121
left: 0.0625rem;
121122
top: 0.0625rem;
122123
right: 0.0625rem;

0 commit comments

Comments
 (0)