Skip to content

Commit

Permalink
implementantion(fix): #29534 Login-as popup show's in the incorrect p…
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoreras authored Aug 20, 2024
1 parent bffd903 commit e463b7b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
<ng-container *ngIf="vm$ | async as vm">
<div
*ngIf="showMask()"
(click)="toogleMenu($event)"
class="dot-mask"
data-testId="dot-mask"></div>
@if (vm$ | async; as vm) {
@if ($showMask()) {
<div (click)="toggleMenu($event)" class="dot-mask" data-testId="dot-mask"></div>
}
<p-avatar
(click)="toogleMenu($event)"
(click)="toggleMenu($event)"
[email]="vm.userData.email"
data-testId="avatar"
dotGravatar></p-avatar>
<p-menu
[model]="vm.items"
[popup]="true"
#menu
(onHide)="hideMask()"
appendTo="body"
styleClass="toolbar-user__menu"></p-menu>

<dot-my-account
*ngIf="vm.showMyAccount"
(shutdown)="store.showMyAccount(false)"
[visible]="vm.showMyAccount"></dot-my-account>
@if (vm.showMyAccount) {
<dot-my-account
(shutdown)="store.showMyAccount(false)"
[visible]="vm.showMyAccount"></dot-my-account>
}

<dot-login-as
*ngIf="vm.showLoginAs"
(cancel)="store.showLoginAs(false)"
[visible]="vm.showLoginAs"></dot-login-as>
</ng-container>
@if (vm.showLoginAs) {
<dot-login-as (cancel)="store.showLoginAs(false)" [visible]="vm.showLoginAs"></dot-login-as>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,17 @@ describe('DotToolbarUserComponent', () => {
fixture.detectChanges();
expect(de.query(By.css('[data-testid="dot-mask"]'))).toBeFalsy();
});

it('should hide mask when menu hide', () => {
fixture.detectChanges();
const avatarComponent = de.query(By.css('[data-testid="avatar"]')).nativeElement;
avatarComponent.click();

const menu = de.query(By.css('p-menu'));
menu.triggerEventHandler('onHide', {});

fixture.detectChanges();

expect(de.query(By.css('[data-testId="dot-mask"]'))).toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AsyncPipe, NgIf } from '@angular/common';
import { AsyncPipe } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
OnInit,
ViewChild,
inject,
signal
signal,
viewChild
} from '@angular/core';

import { AvatarModule } from 'primeng/avatar';
Expand Down Expand Up @@ -33,23 +33,26 @@ import { DotMyAccountModule } from '../dot-my-account/dot-my-account.module';
DotMyAccountModule,
DotSafeHtmlPipe,
MenuModule,
AsyncPipe,
NgIf
AsyncPipe
]
})
export class DotToolbarUserComponent implements OnInit {
readonly #store = inject(DotToolbarUserStore);
readonly store = inject(DotToolbarUserStore);

vm$ = this.#store.vm$;
@ViewChild('menu') menu: Menu;
showMask = signal<boolean>(false);
vm$ = this.store.vm$;
$menu = viewChild<Menu>('menu');
$showMask = signal<boolean>(false);

ngOnInit(): void {
this.#store.init();
this.store.init();
}

toogleMenu(event: CustomEvent): void {
this.menu.toggle(event);
this.showMask.update((value) => !value);
toggleMenu(event: Event): void {
this.$menu().toggle(event);
this.$showMask.update((value) => !value);
}

hideMask(): void {
this.$showMask.update(() => false);
}
}

0 comments on commit e463b7b

Please sign in to comment.