-import { Component, OnDestroy, OnInit } from '@angular/core';
+import { Component, OnDestroy, OnInit, ViewChild, ElementRef } from '@angular/core';
import { Router } from '@angular/router';
import * as _ from 'lodash';
autoHide: false
};
displayedSubMenu = {};
+ @ViewChild('sidenavContainer') sidenavContainer: ElementRef;
private subs = new Subscription();
clustersMap: Map<string, any> = new Map<string, any>();
return undefined;
}
+ onMenuClick(event: MouseEvent) {
+ const target = event.target;
+ if (!(target instanceof HTMLElement)) return;
+ const menuElement: Element = target.closest('cds-sidenav-menu');
+
+ if (menuElement) {
+ const clientViewBounding = menuElement.getBoundingClientRect();
+ const isOutOfView =
+ clientViewBounding.top < 0 || clientViewBounding.bottom > window.innerHeight;
+
+ if (isOutOfView) {
+ menuElement.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
+ }
+ }
+ }
+
toggleSubMenu(menu: string) {
this.displayedSubMenu[menu] = !this.displayedSubMenu[menu];
}