Skip to content

Commit 677d07c

Browse files
authoredMar 9, 2020
fix: explicitly set an index for each API docs section (#732)
1 parent 952b0b4 commit 677d07c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed
 

‎material.angular.io/src/app/pages/component-viewer/component-api.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
(contentRendered)="updateTableOfContents(docItem!.name, $event)">
1515
</doc-viewer>
1616

17-
<doc-viewer *ngFor="let additionalApiDoc of docItem!.additionalApiDocs"
17+
<doc-viewer *ngFor="let additionalApiDoc of docItem!.additionalApiDocs; let index = index"
1818
documentUrl="/docs-content/api-docs/{{additionalApiDoc.path}}"
1919
class="docs-component-view-text-content docs-component-api"
20-
(contentRendered)="updateTableOfContents(additionalApiDoc.name, $event)">
20+
(contentRendered)="updateTableOfContents(additionalApiDoc.name, $event, index + 1)">
2121
</doc-viewer>
2222
</span>
2323

‎material.angular.io/src/app/pages/component-viewer/component-viewer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ export class ComponentBaseView implements OnInit, OnDestroy {
9999
this.destroyed.next();
100100
}
101101

102-
updateTableOfContents(sectionName: string, docViewerContent: HTMLElement) {
102+
updateTableOfContents(sectionName: string, docViewerContent: HTMLElement, sectionIndex = 0) {
103103
if (this.tableOfContents) {
104-
this.tableOfContents.addHeaders(sectionName, docViewerContent);
104+
this.tableOfContents.addHeaders(sectionName, docViewerContent, sectionIndex);
105105
this.tableOfContents.updateScrollPosition();
106106
}
107107
}

‎material.angular.io/src/app/shared/table-of-contents/table-of-contents.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class TableOfContents implements OnInit, AfterViewInit, OnDestroy {
104104
this._links = [];
105105
}
106106

107-
addHeaders(sectionName: string, docViewerContent: HTMLElement) {
107+
addHeaders(sectionName: string, docViewerContent: HTMLElement, sectionIndex = 0) {
108108
const headers = Array.from<HTMLHeadingElement>(docViewerContent.querySelectorAll('h3, h4'));
109109
const links: Link[] = [];
110110
headers.forEach((header) => {
@@ -119,7 +119,7 @@ export class TableOfContents implements OnInit, AfterViewInit, OnDestroy {
119119
active: false
120120
});
121121
});
122-
this._linkSections.push({name: sectionName, links});
122+
this._linkSections[sectionIndex] = {name: sectionName, links};
123123
this._links.push(...links);
124124
}
125125

0 commit comments

Comments
 (0)
Please sign in to comment.