Merge pull request #7932 from opf/fix/31721-remove-event-listener

[31721] Remove FocusOut event which breaks iOS Safari menu
pull/7936/head
ulferts 5 years ago committed by GitHub
commit cf8792b1dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      frontend/src/app/components/main-menu/main-menu-toggle.service.ts

@ -95,8 +95,6 @@ export class MainMenuToggleService {
if (!this.showNavigation) { // sidebar is hidden -> show menu if (!this.showNavigation) { // sidebar is hidden -> show menu
if (this.deviceService.isMobile) { // mobile version if (this.deviceService.isMobile) { // mobile version
this.setWidth(window.innerWidth); this.setWidth(window.innerWidth);
// On mobile the main menu shall close whenever you click outside the menu.
this.setupAutocloseMainMenu();
} else { // desktop version } else { // desktop version
this.saveWidth(parseInt(window.OpenProject.guardedLocalStorage(this.localStorageKey) as string)); this.saveWidth(parseInt(window.OpenProject.guardedLocalStorage(this.localStorageKey) as string));
} }
@ -169,28 +167,6 @@ export class MainMenuToggleService {
this.htmlNode.style.setProperty("--main-menu-width", this.elementWidth + 'px'); this.htmlNode.style.setProperty("--main-menu-width", this.elementWidth + 'px');
} }
private setupAutocloseMainMenu():void {
let that = this;
jQuery('#main-menu').off('focusout.main_menu');
jQuery('#main-menu').on('focusout.main_menu', function (event) {
let originalEvent = event.originalEvent as FocusEvent;
// Check that main menu is not closed and that the `focusout` event is not a click on an element
// that tries to close the menu anyways.
if (!that.showNavigation || document.getElementById('main-menu-toggle') === originalEvent.relatedTarget) {
return;
}
else {
// There might be a time gap between `focusout` and the focussing of the activeElement, thus we need a timeout.
setTimeout(function() {
if (!jQuery.contains(document.getElementById('main-menu')!, originalEvent.relatedTarget as Element)) {
// activeElement is outside of main menu.
that.closeMenu();
}
}, 0);
}
});
}
private snapBack():void { private snapBack():void {
if (this.elementWidth <= 10) { if (this.elementWidth <= 10) {
this.elementWidth = 0; this.elementWidth = 0;

Loading…
Cancel
Save