diff --git a/src/app/shared/menu/menu.component.ts b/src/app/shared/menu/menu.component.ts index 1e81fa2dda..142471224d 100644 --- a/src/app/shared/menu/menu.component.ts +++ b/src/app/shared/menu/menu.component.ts @@ -3,7 +3,7 @@ import { Observable } from 'rxjs/internal/Observable'; import { MenuService } from '../../shared/menu/menu.service'; import { MenuID } from '../../shared/menu/initial-menus-state'; import { MenuSection } from '../../shared/menu/menu.reducer'; -import { first, map } from 'rxjs/operators'; +import { distinctUntilChanged, first, map } from 'rxjs/operators'; import { GenericConstructor } from '../../core/shared/generic-constructor'; import { hasValue } from '../empty.util'; import { MenuSectionComponent } from './menu-section/menu-section.component'; @@ -72,7 +72,7 @@ export class MenuComponent implements OnInit { this.menuCollapsed = this.menuService.isMenuCollapsed(this.menuID); this.menuPreviewCollapsed = this.menuService.isMenuPreviewCollapsed(this.menuID); this.menuVisible = this.menuService.isMenuVisible(this.menuID); - this.sections = this.menuService.getMenuTopSections(this.menuID).pipe(first()); + this.sections = this.menuService.getMenuTopSections(this.menuID).pipe(distinctUntilChanged((x, y) => x.length === y.length)); this.sections.subscribe((sections: MenuSection[]) => { sections.forEach((section: MenuSection) => { this.sectionInjectors.set(section.id, this.getSectionDataInjector(section)); diff --git a/src/app/shared/menu/menu.reducer.ts b/src/app/shared/menu/menu.reducer.ts index 078343a990..e5a30770d8 100644 --- a/src/app/shared/menu/menu.reducer.ts +++ b/src/app/shared/menu/menu.reducer.ts @@ -176,7 +176,9 @@ function removeSection(state: MenusState, action: RemoveMenuSectionAction) { const menuState: MenuState = state[action.menuID]; const id = action.id; const newState = removeFromIndex(state, menuState.sections[action.id], action.menuID); - const newMenuState = Object.assign({}, newState[action.menuID]); + const newMenuState = Object.assign({}, newState[action.menuID], { + sections: Object.assign({}, newState[action.menuID].sections) + }); delete newMenuState.sections[id]; return Object.assign({}, newState, { [action.menuID]: newMenuState }); }