Open the main menu with

default width when the last saved width was 0
pull/8323/head
Aleix Suau 5 years ago
parent 440b811c9d
commit cf2010cbeb
  1. 13
      frontend/src/app/components/main-menu/main-menu-toggle.service.ts

@ -36,11 +36,11 @@ import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
@Injectable({ providedIn: 'root' })
export class MainMenuToggleService {
public toggleTitle:string;
private elementWidth:number;
private elementMinWidth = 11;
private readonly defaultWidth:number = 230;
private readonly localStorageKey:string = 'openProject-mainMenuWidth';
private readonly localStorageStateKey:string = 'openProject-mainMenuCollapsed';
private readonly defaultWidth:number = 230;
@InjectField() currentProject:CurrentProjectService;
@ -97,7 +97,10 @@ export class MainMenuToggleService {
if (this.deviceService.isMobile) { // mobile version
this.setWidth(window.innerWidth);
} else { // desktop version
this.saveWidth(parseInt(window.OpenProject.guardedLocalStorage(this.localStorageKey) as string));
const savedWidth = parseInt(window.OpenProject.guardedLocalStorage(this.localStorageKey) as string);
const widthToSave = savedWidth >= this.elementMinWidth ? savedWidth : this.defaultWidth;
this.saveWidth(widthToSave);
}
} else { // sidebar is expanded -> close menu
this.closeMenu();
@ -156,11 +159,11 @@ export class MainMenuToggleService {
}
public get showNavigation():boolean {
return (this.elementWidth > 10);
return (this.elementWidth >= this.elementMinWidth);
}
private snapBack():void {
if (this.elementWidth <= 10) {
if (this.elementWidth < this.elementMinWidth) {
this.elementWidth = 0;
}
}

Loading…
Cancel
Save