Skip to content

feat: expose replaceHistory option via navigable tab component #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ import { NavigableTabComponent } from './navigable-tab.component';
<nav mat-tab-nav-bar *htLetAsync="this.activeTab$ as activeTab" disableRipple>
<ng-container *ngFor="let tab of this.tabs">
<ng-container *ngIf="!tab.hidden">
<ht-link [paramsOrUrl]="buildNavigationParam | htMemoize: tab">
<div class="tab-button" *htIfFeature="tab.featureFlags | htFeature as featureState">
<a mat-tab-link (click)="this.onTabClick(tab)" class="tab-link" [active]="activeTab === tab">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure it is still able to set active attribute for mat-tab link? This is why I had kept the ht-link outside the mat-tab-link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. its setting active tab correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thank you!

<ng-container *ngTemplateOutlet="tab.content"></ng-container>
<span *ngIf="featureState === '${FeatureState.Preview}'" class="soon-container">
<span class="soon">SOON</span>
</span>
</a>
<div class="ink-bar" [ngClass]="{ active: activeTab === tab }"></div>
</div>
</ht-link>
<div class="tab-button" *htIfFeature="tab.featureFlags | htFeature as featureState">
<ht-link mat-tab-link [paramsOrUrl]="buildNavParamsForTab | htMemoize: tab" class="tab-link">
<ng-container *ngTemplateOutlet="tab.content"></ng-container>
<span *ngIf="featureState === '${FeatureState.Preview}'" class="soon-container">
<span class="soon">SOON</span>
</span>
</ht-link>
<div class="ink-bar" [ngClass]="{ active: activeTab === tab }"></div>
</div>
</ng-container>
</ng-container>
</nav>
Expand All @@ -50,16 +48,13 @@ export class NavigableTabGroupComponent implements AfterContentInit {
);
}

public buildNavigationParam = (tab: NavigableTabComponent): NavigationParams => ({
public buildNavParamsForTab = (tab: NavigableTabComponent): NavigationParams => ({
navType: NavigationParamsType.InApp,
path: [tab.path],
relativeTo: this.activatedRoute
path: tab.path,
relativeTo: this.activatedRoute,
replaceCurrentHistory: tab.replaceHistory
});

public onTabClick(tab: NavigableTabComponent): void {
this.navigationService.navigateWithinApp([tab.path], this.activatedRoute);
}

private findActiveTab(): NavigableTabComponent | undefined {
return this.tabs.find(tab => this.navigationService.isRelativePathActive([tab.path], this.activatedRoute));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class NavigableTabComponent extends ContentHolder {
@Input()
public hidden: boolean = false;

@Input()
public replaceHistory?: boolean;

@Input()
public features: string[] = [];

Expand Down
1 change: 1 addition & 0 deletions projects/components/src/tabs/navigable/navigable-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export interface NavigableTab {
label: string;
hidden?: boolean;
features?: string[];
replaceHistory?: boolean;
}