Skip to content
Snippets Groups Projects
Commit 63fe5b66 authored by Tögl, Christina's avatar Tögl, Christina
Browse files

Add event for clicking outside of menu (mobile)

parent c36ff13e
No related branches found
No related tags found
No related merge requests found
Pipeline #84259 passed
...@@ -68,6 +68,9 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -68,6 +68,9 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
this._attrObserver = new MutationObserver(this.onAttributeObserved); this._attrObserver = new MutationObserver(this.onAttributeObserved);
this._onShowActivityEvent = this._onShowActivityEvent.bind(this); this._onShowActivityEvent = this._onShowActivityEvent.bind(this);
this.boundCloseMenuHandler = this.hideMenu.bind(this);
this.initateOpenMenu = false;
this.auth = {}; this.auth = {};
} }
...@@ -475,9 +478,22 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -475,9 +478,22 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
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';
} }
if (!menu.classList.contains('hidden')) {
document.addEventListener('click', this.boundCloseMenuHandler);
this.initateOpenMenu = true;
}
else {
document.removeEventListener('click', this.boundCloseMenuHandler);
menu.removeAttribute('style');
}
} }
hideMenu() { hideMenu() {
if (this.initateOpenMenu) {
this.initateOpenMenu = false;
return;
}
const menu = this.shadowRoot.querySelector("ul.menu"); const menu = this.shadowRoot.querySelector("ul.menu");
if (menu && !menu.classList.contains('hidden')) if (menu && !menu.classList.contains('hidden'))
this.toggleMenu(); this.toggleMenu();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment