Skip to content

Commit

Permalink
fix(markdown-navigator): fix for markdown navigator breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed May 19, 2022
1 parent d3c0c87 commit 8d4dd16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
Expand Up @@ -19,7 +19,7 @@
<ng-container *ngIf="!isLast; else lastBreadCrumb">
<a
td-breadcrumb
(click)="goBack(index)"
(click)="goBack(historyStack.length - index)"
[attr.data-test]="'back-button'"
>{{ stack.title }}</a
>
Expand Down
42 changes: 19 additions & 23 deletions libs/markdown-navigator/src/markdown-navigator.component.ts
Expand Up @@ -151,7 +151,7 @@ export class TdMarkdownNavigatorComponent implements OnChanges {
}

get showHeader(): boolean {
return this.showGoBackButton || !!this.currentItemTitle;
return !!this.currentItemTitle;
}

get showMenu(): boolean {
Expand Down Expand Up @@ -232,9 +232,7 @@ export class TdMarkdownNavigatorComponent implements OnChanges {
}

get currentItemTitle(): string {
if (this.historyStack.length < 1) {
return '';
} else if (this.currentMarkdownItem) {
if (this.currentMarkdownItem) {
return this.getTitle(this.currentMarkdownItem);
} else if (this.historyStack.length > 0) {
return this.getTitle(this.historyStack[this.historyStack.length - 1]);
Expand Down Expand Up @@ -278,29 +276,27 @@ export class TdMarkdownNavigatorComponent implements OnChanges {
this._changeDetectorRef.markForCheck();
}

goBack(goBackLength = 1): void {
goBack(goBackLength = 2): void {
this.loading = false;
this.clearErrors();
if (this.historyStack.length > 1) {
let parent: IMarkdownNavigatorItem | undefined =
this.historyStack[this.historyStack.length - 2];

if (parent?.startAtLink) {
parent = this.historyStack[this.historyStack.length - 3]
? this.historyStack[this.historyStack.length - 3]
: undefined;
this.historyStack = this.historyStack.slice(0, -goBackLength);
}
let parent: IMarkdownNavigatorItem | undefined =
this.historyStack[this.historyStack.length - goBackLength];

if (parent?.startAtLink) {
parent = this.historyStack[this.historyStack.length - 3]
? this.historyStack[this.historyStack.length - 3]
: undefined;
this.historyStack = this.historyStack.slice(0, -goBackLength);
}

if (parent) {
this.currentMarkdownItem = parent;
this.historyStack = this.historyStack.slice(0, -goBackLength);
this.setChildrenAsCurrentMenuItems(parent);
} else {
this.reset();
}
if (parent) {
this.currentMarkdownItem = parent;
this.historyStack = this.historyStack.slice(
0,
this.historyStack.length - goBackLength + 1
);
this.setChildrenAsCurrentMenuItems(parent);
} else {
// one level down just go to root
this.reset();
}
this._changeDetectorRef.markForCheck();
Expand Down

0 comments on commit 8d4dd16

Please sign in to comment.