Fix dropdown visibility when using only 1 random network
This commit is contained in:
parent
9dbf3b54fb
commit
c0ec9f70c3
@ -62,7 +62,7 @@
|
||||
}
|
||||
</a>
|
||||
|
||||
<div (window:resize)="onResize()" ngbDropdown class="dropdown-container" *ngIf="env.TESTNET_ENABLED || env.TESTNET4_ENABLED || env.SIGNET_ENABLED || env.LIQUID_ENABLED || env.LIQUID_TESTNET_ENABLED">
|
||||
<div (window:resize)="onResize()" ngbDropdown class="dropdown-container" *ngIf="isDropdownVisible">
|
||||
<button ngbDropdownToggle type="button" class="btn btn-secondary dropdown-toggle-split d-flex justify-content-center align-items-center" aria-haspopup="true">
|
||||
<app-svg-images class="d-flex justify-content-center align-items-center current-network-svg" [name]="network.val === '' ? 'bitcoin' : network.val" width="20" height="20" viewBox="0 0 65 65"></app-svg-images>
|
||||
</button>
|
||||
|
@ -31,6 +31,7 @@ export class MasterPageComponent implements OnInit, OnDestroy {
|
||||
user: any = undefined;
|
||||
servicesEnabled = false;
|
||||
menuOpen = false;
|
||||
isDropdownVisible: boolean;
|
||||
|
||||
enterpriseInfo: any;
|
||||
enterpriseInfo$: Subscription;
|
||||
@ -74,19 +75,27 @@ export class MasterPageComponent implements OnInit, OnDestroy {
|
||||
|
||||
const isServicesPage = this.router.url.includes('/services/');
|
||||
this.menuOpen = isServicesPage && !this.isSmallScreen();
|
||||
this.setDropdownVisibility();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.enterpriseInfo$) {
|
||||
this.enterpriseInfo$.unsubscribe();
|
||||
}
|
||||
setDropdownVisibility(): void {
|
||||
const networks = [
|
||||
this.env.TESTNET_ENABLED,
|
||||
this.env.TESTNET4_ENABLED,
|
||||
this.env.SIGNET_ENABLED,
|
||||
this.env.LIQUID_ENABLED,
|
||||
this.env.LIQUID_TESTNET_ENABLED,
|
||||
this.env.MAINNET_ENABLED,
|
||||
];
|
||||
const enabledNetworksCount = networks.filter((networkEnabled) => networkEnabled).length;
|
||||
this.isDropdownVisible = enabledNetworksCount > 1;
|
||||
}
|
||||
|
||||
collapse(): void {
|
||||
this.navCollapsed = !this.navCollapsed;
|
||||
}
|
||||
|
||||
isSmallScreen() {
|
||||
isSmallScreen(): boolean {
|
||||
return window.innerWidth <= 767.98;
|
||||
}
|
||||
|
||||
@ -117,4 +126,11 @@ export class MasterPageComponent implements OnInit, OnDestroy {
|
||||
menuToggled(isOpen: boolean): void {
|
||||
this.menuOpen = isOpen;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.enterpriseInfo$) {
|
||||
this.enterpriseInfo$.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user