Skip to content

Commit d1209c5

Browse files
authored
no userInfo for profile-menu (#2339)
* fix(header): fixes issue when no service links are provided in hide-login mode for profile-menu
1 parent 1c98c49 commit d1209c5

File tree

3 files changed

+614
-14
lines changed

3 files changed

+614
-14
lines changed

packages/components/src/components/telekom/telekom-profile-menu/telekom-profile-menu.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ scale-telekom-profile-menu scale-menu-flyout {
6868
height: 12px;
6969
}
7070

71-
.scale-telekom-nav-item > button {
71+
scale-telekom-profile-menu .scale-telekom-nav-item > button {
7272
padding-bottom: var(--_spacing-bottom-slotted-bottom);
7373
}
7474

packages/components/src/components/telekom/telekom-profile-menu/telekom-profile-menu.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class TelekomProfileMenu {
165165
buildLogoutButton() {
166166
return {
167167
type: 'button',
168-
name: this.logoutLabel,
168+
name: this.logoutLabel || 'Logout',
169169
href: this.logoutUrl || LOGOUT_DEFAULT,
170170
variant: 'secondary',
171171
onClick: this.logoutHandler,
@@ -176,17 +176,11 @@ export class TelekomProfileMenu {
176176
const divider = [{ type: 'divider' }];
177177

178178
const userInfo = readData(this.userInfo);
179-
if (!userInfo) {
180-
// console.error("userInfo missing");
181-
}
182-
userInfo.type = 'userInfo';
183-
184-
let serviceLinks = readData(this.serviceLinks);
185-
if (!serviceLinks) {
186-
// console.error("serviceLinks missing");
187-
serviceLinks = [];
179+
if (userInfo) {
180+
userInfo.type = 'userInfo';
188181
}
189182

183+
const serviceLinks = readData(this.serviceLinks) || [];
190184
for (const el of serviceLinks) {
191185
el.type = 'item';
192186
}
@@ -200,9 +194,11 @@ export class TelekomProfileMenu {
200194

201195
let menu = [];
202196

203-
menu = menu.concat(userInfo);
197+
if (userInfo) {
198+
menu = menu.concat(userInfo);
199+
}
204200

205-
if (!this.serviceLinksEmpty()) {
201+
if (userInfo && !this.serviceLinksEmpty()) {
206202
menu = menu.concat(divider);
207203
}
208204

@@ -221,7 +217,10 @@ export class TelekomProfileMenu {
221217
}
222218

223219
serviceLinksEmpty() {
224-
return (this.hideLoginSettings && this.serviceLinks.length < 1) === true;
220+
return (
221+
this.hideLoginSettings &&
222+
(!this.serviceLinks || this.serviceLinks.length < 1)
223+
);
225224
}
226225

227226
buildDesktopMenuStyles() {

0 commit comments

Comments
 (0)