diff --git a/package.json b/package.json index ebcc50f9..8a030a30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redoc", - "version": "2.0.0-0.1.1", + "version": "2.0.0-0.2.0", "description": "ReDoc", "repository": { "type": "git", diff --git a/src/services/AppStore.ts b/src/services/AppStore.ts index 0f166595..0c0dba35 100644 --- a/src/services/AppStore.ts +++ b/src/services/AppStore.ts @@ -72,6 +72,9 @@ export class AppStore { // update position statically based on hash (in case of SSR) MenuStore.updateOnHistory(this.history.currentId, this.scroll); + // Listen for external event to update + window.addEventListener('redocUpdatePosition', this.updateOnEvent); + // override the openApi standard to version 3.1.0 // TODO remove when fully supporting open API 3.1.0 spec.openapi = '3.1.0'; @@ -98,6 +101,7 @@ export class AppStore { dispose() { this.scroll.dispose(); this.menu.dispose(); + window.removeEventListener('redocUpdatePosition', this.updateOnEvent); if (this.search) { this.search.dispose(); } @@ -125,6 +129,10 @@ export class AppStore { }; } + private updateOnEvent(): void { + MenuStore.updateOnHistory(this.history.currentId, this.scroll); + } + private updateMarkOnMenu(idx: number) { const start = Math.max(0, idx); const end = Math.min(this.menu.flatItems.length, start + 5);