Skip to content
Snippets Groups Projects

Add scrollbar to menu if necessary

Merged Tögl, Christina requested to merge scrollable-menu into master
4 unresolved threads
@@ -56,6 +56,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
@@ -56,6 +56,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
this.basePath = '/';
this.basePath = '/';
this.keycloakConfig = null;
this.keycloakConfig = null;
this.noWelcomePage = false;
this.noWelcomePage = false;
 
this.menuHeight = -1;
this._updateAuth = this._updateAuth.bind(this);
this._updateAuth = this._updateAuth.bind(this);
this._loginStatus = 'unknown';
this._loginStatus = 'unknown';
@@ -363,7 +364,6 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
@@ -363,7 +364,6 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
this.updatePageTitle();
this.updatePageTitle();
this.subtitle = this.activeMetaDataText("short_name");
this.subtitle = this.activeMetaDataText("short_name");
this.description = this.activeMetaDataText("description");
this.description = this.activeMetaDataText("description");
};
};
// If it is empty assume the element is already registered through other means
// If it is empty assume the element is already registered through other means
@@ -399,13 +399,31 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
@@ -399,13 +399,31 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
toggleMenu() {
toggleMenu() {
const menu = this.shadowRoot.querySelector("ul.menu");
const menu = this.shadowRoot.querySelector("ul.menu");
 
const subtitle = this.shadowRoot.querySelector("h2.subtitle");
if (menu === null) {
if (menu === null || subtitle === null) {
return;
return;
}
}
menu.classList.toggle('hidden');
menu.classList.toggle('hidden');
 
if (this.menuHeight === -1) {
 
this.menuHeight = menu.clientHeight;
 
}
 
 
let topValue = subtitle.getBoundingClientRect().bottom;
 
let isMenuOverflow = this.menuHeight + topValue >= window.innerHeight ? true : false;
 
 
if (isMenuOverflow && !menu.classList.contains('hidden')) {
 
menu.setAttribute('style', 'position: fixed;top: ' + topValue + 'px;bottom: 0;border-bottom: 0;overflow-y: auto;');
 
menu.scrollTop = 0;
 
document.body.setAttribute('style', 'overflow:hidden;');
 
 
} else if (isMenuOverflow && menu.classList.contains('hidden')) {
 
document.body.removeAttribute('style', 'overflow:hidden;');
 
menu.setAttribute('style', 'position: fixed;top: ' + topValue + 'px;bottom: 0;border-bottom: 0;overflow-y: auto;');
 
}
 
const chevron = this.shadowRoot.querySelector("#menu-chevron-icon");
const chevron = this.shadowRoot.querySelector("#menu-chevron-icon");
if (chevron !== null) {
if (chevron !== null) {
chevron.name = menu.classList.contains('hidden') ? 'chevron-down' : 'chevron-up';
chevron.name = menu.classList.contains('hidden') ? 'chevron-down' : 'chevron-up';
@@ -635,8 +653,6 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
@@ -635,8 +653,6 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
position: absolute;
position: absolute;
background-color: white;
background-color: white;
z-index: 10;
z-index: 10;
overflow-y: scroll;
white-space: nowrap;
}
}
.menu li {
.menu li {
Loading