mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-23 00:56:33 +03:00
Fix changeDetection in Safari
This commit is contained in:
parent
a1a1739508
commit
50a378f3ea
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { ElementRef } from '@angular/core';
|
import { ElementRef, ChangeDetectorRef } from '@angular/core';
|
||||||
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
import { global } from '@angular/core/src/facade/lang';
|
import { global } from '@angular/core/src/facade/lang';
|
||||||
|
|
||||||
|
@ -13,10 +13,11 @@ import { ScrollService, Hash, MenuService, OptionsService } from '../../services
|
||||||
providers: [ScrollService, MenuService, Hash],
|
providers: [ScrollService, MenuService, Hash],
|
||||||
styleUrls: ['./lib/components/SideMenu/side-menu.css']
|
styleUrls: ['./lib/components/SideMenu/side-menu.css']
|
||||||
})
|
})
|
||||||
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef],
|
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], [BrowserDomAdapter],
|
||||||
[BrowserDomAdapter], [ScrollService], [MenuService], [Hash], [OptionsService]])
|
[ScrollService], [MenuService], [Hash], [OptionsService], [ChangeDetectorRef]])
|
||||||
export class SideMenu extends BaseComponent {
|
export class SideMenu extends BaseComponent {
|
||||||
constructor(schemaMgr, elementRef, dom, scrollService, menuService, hash, optionsService) {
|
constructor(schemaMgr, elementRef, dom, scrollService,
|
||||||
|
menuService, hash, optionsService, detectorRef) {
|
||||||
super(schemaMgr);
|
super(schemaMgr);
|
||||||
this.$element = elementRef.nativeElement;
|
this.$element = elementRef.nativeElement;
|
||||||
this.dom = dom;
|
this.dom = dom;
|
||||||
|
@ -28,13 +29,17 @@ export class SideMenu extends BaseComponent {
|
||||||
this.activeItemCaption = '';
|
this.activeItemCaption = '';
|
||||||
|
|
||||||
this.options = optionsService.options;
|
this.options = optionsService.options;
|
||||||
|
this.detectorRef = detectorRef;
|
||||||
|
|
||||||
this.menuService.changed.subscribe(this.changed.bind(this));
|
this.menuService.changed.subscribe((cat, item) => this.changed(cat, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
changed(cat, item) {
|
changed(cat, item) {
|
||||||
this.activeCatCaption = cat.name || '';
|
this.activeCatCaption = cat.name || '';
|
||||||
this.activeItemCaption = item && item.summary || '';
|
this.activeItemCaption = item && item.summary || '';
|
||||||
|
|
||||||
|
//safari doesn't update bindings if not run changeDetector manually :(
|
||||||
|
this.detectorRef.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
activateAndScroll(idx, methodIdx) {
|
activateAndScroll(idx, methodIdx) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user