mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-10-31 15:57:30 +03:00 
			
		
		
		
	Fix latest empty menu-items not getting active (#194)
This commit is contained in:
		
							parent
							
								
									555767feb5
								
							
						
					
					
						commit
						9b6a97fc64
					
				|  | @ -52,6 +52,7 @@ export class MenuService { | ||||||
|   private _flatItems: MenuItem[]; |   private _flatItems: MenuItem[]; | ||||||
|   private _hashSubscription: Subscription; |   private _hashSubscription: Subscription; | ||||||
|   private _scrollSubscription: Subscription; |   private _scrollSubscription: Subscription; | ||||||
|  |   private _progressSubscription: Subscription; | ||||||
|   private _tagsWithMethods: any; |   private _tagsWithMethods: any; | ||||||
| 
 | 
 | ||||||
|   constructor( |   constructor( | ||||||
|  | @ -71,6 +72,12 @@ export class MenuService { | ||||||
|     this._hashSubscription =  this.hash.value.subscribe((hash) => { |     this._hashSubscription =  this.hash.value.subscribe((hash) => { | ||||||
|       this.onHashChange(hash); |       this.onHashChange(hash); | ||||||
|     }); |     }); | ||||||
|  | 
 | ||||||
|  |     this._progressSubscription = this.tasks.loadProgress.subscribe(progress => { | ||||||
|  |       if (progress === 100) { | ||||||
|  |         this.makeSureLastItemsEnabled(); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   get flatItems():MenuItem[] { |   get flatItems():MenuItem[] { | ||||||
|  | @ -88,7 +95,7 @@ export class MenuService { | ||||||
|       idx = item.parent.flatIdx; |       idx = item.parent.flatIdx; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // check if previous items can be enabled
 |     // check if previous items§ can be enabled
 | ||||||
|     let prevItem = this.flatItems[idx -= 1]; |     let prevItem = this.flatItems[idx -= 1]; | ||||||
|     while(prevItem && (!prevItem.metadata || !prevItem.items)) { |     while(prevItem && (!prevItem.metadata || !prevItem.items)) { | ||||||
|       prevItem.ready = true; |       prevItem.ready = true; | ||||||
|  | @ -98,6 +105,15 @@ export class MenuService { | ||||||
|     this.changed.next(); |     this.changed.next(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   makeSureLastItemsEnabled() { | ||||||
|  |     let lastIdx = this.flatItems.length - 1; | ||||||
|  |     let item = this.flatItems[lastIdx] | ||||||
|  |     while(item && (!item.metadata || !item.items)) { | ||||||
|  |       item.ready = true; | ||||||
|  |       item = this.flatItems[lastIdx -= 1]; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   onScroll(isScrolledDown) { |   onScroll(isScrolledDown) { | ||||||
|     let stable = false; |     let stable = false; | ||||||
|     while(!stable) { |     while(!stable) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user