Skip to content

Commit 5164035

Browse files
dobromiraboychevaadrian-bobev
andauthoredMar 18, 2025··
feat(ui5-user-menu): design enhancements (#11124)
--------- Co-authored-by: Adrian Bobev <[email protected]>
1 parent a4565fe commit 5164035

File tree

11 files changed

+296
-160
lines changed

11 files changed

+296
-160
lines changed
 

‎packages/fiori/cypress/specs/UserMenu.cy.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe("Initial rendering", () => {
7575
cy.get("@userMenu").should("exist");
7676
cy.get("@userMenu").shadow().find("[ui5-responsive-popover]").as("responsivePopover");
7777
cy.get("@responsivePopover").should("exist");
78-
cy.get("@responsivePopover").find("[ui5-panel]").contains(`${USER_MENU_OTHER_ACCOUNT_BUTTON_TXT.defaultText} (1)`);
78+
cy.get("@responsivePopover").find("[ui5-panel]").contains(`${USER_MENU_OTHER_ACCOUNT_BUTTON_TXT.defaultText} (2)`);
7979
cy.get("@responsivePopover").find("[ui5-button]").should("have.length", 1);
8080
});
8181

@@ -105,7 +105,7 @@ describe("Initial rendering", () => {
105105
cy.get("@userMenu").should("exist");
106106
cy.get("@userMenu").shadow().find("[ui5-responsive-popover]").as("responsivePopover");
107107
cy.get("@responsivePopover").should("exist");
108-
cy.get("@responsivePopover").find(".ui5-pm-add-account-btn").should("exist");
108+
cy.get("@responsivePopover").find(".ui5-user-menu-add-account-btn").should("exist");
109109
cy.get("@responsivePopover").find("[ui5-button]").should("have.length", 2);
110110
});
111111
});
@@ -338,7 +338,7 @@ describe("Events", () => {
338338
cy.get("@clicked").should("have.been.calledOnce");
339339
});
340340

341-
it("tests add-account-click event", () => {
341+
it("tests edit-accounts-click event", () => {
342342
cy.mount(
343343
<>
344344
<Button id="openUserMenuBtn">Open User Menu</Button>
@@ -351,7 +351,7 @@ describe("Events", () => {
351351
cy.get("[ui5-user-menu]").as("userMenu");
352352
cy.get("@userMenu")
353353
.shadow()
354-
.find(".ui5-pm-add-account-btn")
354+
.find(".ui5-user-menu-add-account-btn")
355355
.as("addAccountBtn");
356356

357357
cy.get("@userMenu")
@@ -369,8 +369,8 @@ describe("Events", () => {
369369
<>
370370
<Button id="openUserMenuBtn">Open User Menu</Button>
371371
<UserMenu open={true} opener="openUserMenuBtn" showOtherAccounts={true}>
372-
<UserMenuAccount slot="accounts" titleText="Alain Chevalier 1"></UserMenuAccount>
373372
<UserMenuAccount slot="accounts" titleText="Alain Chevalier 2"></UserMenuAccount>
373+
<UserMenuAccount selected slot="accounts" titleText="Alain Chevalier 1"></UserMenuAccount>
374374
</UserMenu>
375375
</>
376376
);
@@ -390,7 +390,7 @@ describe("Events", () => {
390390
.click();
391391

392392
cy.get("@otherAccounts")
393-
.find("[ui5-li-custom]")
393+
.find("[ui5-li-custom]").first()
394394
.click();
395395

396396
cy.get("@changedAccount").should("have.been.calledOnce");
@@ -434,7 +434,7 @@ describe("Events", () => {
434434
cy.get("@avatar").find("img").as("image");
435435
cy.get("@image").should("have.length", 1);
436436
cy.get("@image").should("have.attr", "src", "./../../test/pages/img/man_avatar_1.png");
437-
cy.get("@avatar").should("have.class", "ui5-pm--selected-account-avatar");
437+
cy.get("@avatar").should("have.class", "ui5-user-menu--selected-account-avatar");
438438
});
439439

440440
it("tests item-click event", () => {
@@ -623,7 +623,7 @@ describe("Responsiveness", () => {
623623
cy.get("[ui5-user-menu]").as("userMenu");
624624
cy.get("@userMenu").should("exist");
625625
cy.get("@userMenu").shadow().find("[ui5-bar]").as("headerBar");
626-
cy.get("@headerBar").should("have.class", "ui5-pm-phone-header");
626+
cy.get("@headerBar").should("have.class", "ui5-user-menu-fixed-header");
627627
});
628628

629629
it("tests scroll on phone", () => {

‎packages/fiori/src/UserMenu.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { ListItemClickEventDetail } from "@ui5/webcomponents/dist/List.js";
1111
import type ListItemBase from "@ui5/webcomponents/dist/ListItemBase.js";
1212
import type ResponsivePopover from "@ui5/webcomponents/dist/ResponsivePopover.js";
1313
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
14+
import type { PopupScrollEventDetail } from "@ui5/webcomponents/dist/Popup.js";
1415
import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
1516
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js";
1617
import type UserMenuAccount from "./UserMenuAccount.js";
@@ -27,6 +28,9 @@ import {
2728
USER_MENU_EDIT_AVATAR_TXT,
2829
USER_MENU_EDIT_ACCOUNTS_TXT,
2930
USER_MENU_CLOSE_DIALOG_BUTTON,
31+
USER_MENU_POPOVER_ACCESSIBLE_ACCOUNT_SELECTED_TXT,
32+
USER_MENU_CURRENT_INFORMATION_TXT,
33+
USER_MENU_ACTIONS_TXT,
3034
} from "./generated/i18n/i18n-defaults.js";
3135

3236
type UserMenuItemClickEventDetail = {
@@ -235,6 +239,13 @@ class UserMenu extends UI5Element {
235239
@property({ type: Boolean })
236240
_manageAccountMovedToHeader = false;
237241

242+
/**
243+
* @default false
244+
* @private
245+
*/
246+
@property({ type: Boolean })
247+
_isScrolled = false;
248+
238249
/**
239250
* @private
240251
*/
@@ -268,7 +279,7 @@ class UserMenu extends UI5Element {
268279
}
269280

270281
onAfterRendering(): void {
271-
if (this._isPhone && this._responsivePopover) {
282+
if (this._responsivePopover) {
272283
const observerOptions = {
273284
threshold: [0.15],
274285
};
@@ -290,6 +301,10 @@ class UserMenu extends UI5Element {
290301
return isPhone();
291302
}
292303

304+
_handleScroll(e: CustomEvent<PopupScrollEventDetail>) {
305+
this._isScrolled = e.detail.scrollTop > 0;
306+
}
307+
293308
_handleIntersection(entries: IntersectionObserverEntry[]) {
294309
entries.forEach(entry => {
295310
if (entry.isIntersecting) {
@@ -396,7 +411,7 @@ class UserMenu extends UI5Element {
396411
}
397412

398413
get _otherAccounts() {
399-
return this.accounts.filter(account => account !== this._selectedAccount);
414+
return this.accounts;
400415
}
401416

402417
get _manageAccountButtonText() {
@@ -430,6 +445,18 @@ class UserMenu extends UI5Element {
430445
return `${UserMenu.i18nBundle.getText(USER_MENU_POPOVER_ACCESSIBLE_NAME)} ${this._selectedAccount.titleText}`;
431446
}
432447

448+
get _ariaLabelledByAccountInformationText() {
449+
return UserMenu.i18nBundle.getText(USER_MENU_CURRENT_INFORMATION_TXT);
450+
}
451+
452+
get _ariaLabelledByActions() {
453+
return UserMenu.i18nBundle.getText(USER_MENU_ACTIONS_TXT);
454+
}
455+
456+
getAccountDescriptionText(account: UserMenuAccount) {
457+
return `${account.subtitleText} ${account.description} ${account.selected ? UserMenu.i18nBundle.getText(USER_MENU_POPOVER_ACCESSIBLE_ACCOUNT_SELECTED_TXT) : ""}`;
458+
}
459+
433460
getAccountByRefId(refId: string) {
434461
return this.accounts.find(account => account._id === refId)!;
435462
}

‎packages/fiori/src/UserMenuAccount.ts

+9
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ class UserMenuAccount extends UI5Element {
7474
@property({ type: Boolean })
7575
selected = false;
7676

77+
/**
78+
* Indicates whether a loading indicator should be shown.
79+
* @default false
80+
* @public
81+
* @since 2.9.0
82+
*/
83+
@property({ type: Boolean })
84+
loading = false;
85+
7786
get _initials() {
7887
return this.avatarInitials || "undefined";
7988
}

0 commit comments

Comments
 (0)
Please sign in to comment.