Skip to content
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

fix: pass route extras in routerLink #2905

Merged
merged 7 commits into from
May 29, 2024
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
20 changes: 5 additions & 15 deletions src/ui-shell/sidenav/side-nav.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FooComponent { }
@Component({
template: `
<cds-sidenav [allowExpansion]="allowExpansion" [hidden]="hidden">
<cds-sidenav-menu title="Example Title"></cds-sidenav-menu>
<cds-sidenav-menu title="Example Title"></cds-sidenav-menu>
<cds-sidenav-item
[route]="route"
[useRouter]="useRouter"
Expand Down Expand Up @@ -67,7 +67,7 @@ describe("SideNav", () => {
});
});

it("should work", () => {
it("should work", () => {
fixture = TestBed.createComponent(SideNav);
expect(fixture.componentInstance instanceof SideNav).toBe(true);
});
Expand All @@ -81,7 +81,7 @@ describe("SideNav", () => {
fixture.detectChanges();
});

it("should emit the navigation status promise when the link is activated and call onNavigation", async () => {
it("should emit the navigation status promise when the link is activated and call onNavigation", async () => {
wrapper = fixture.componentInstance;
spyOn(wrapper, "onNavigation").and.callThrough();
fixture.detectChanges();
Expand Down Expand Up @@ -110,7 +110,7 @@ describe("SideNav", () => {
it("should set the sidenav-menu title to Example Title", () => {
fixture.detectChanges();
element = fixture.debugElement.query(By.css("cds-sidenav-menu"));
expect(element.nativeElement.textContent).toEqual("Example Title");
expect(element.nativeElement.textContent).toEqual("Example Title");
});

it("should toggle expanded on click", () => {
Expand Down Expand Up @@ -140,16 +140,6 @@ describe("SideNav", () => {
fixture.detectChanges();
});

it("should not emit the navigation status promise when the link is activated and call onNavigation", async () => {
wrapper = fixture.componentInstance;
spyOn(wrapper, "onNavigation").and.callThrough();
fixture.detectChanges();
element = fixture.debugElement.query(By.css(".cds--side-nav__link"));
element.nativeElement.click();
fixture.detectChanges();
expect(wrapper.onNavigation).not.toHaveBeenCalled();
});

it("should expand sidenav-menu on click", () => {
wrapper = fixture.componentInstance;
fixture.detectChanges();
Expand All @@ -167,7 +157,7 @@ describe("SideNav", () => {
it("should set the sidenav-menu title to Example Title", () => {
fixture.detectChanges();
element = fixture.debugElement.query(By.css("cds-sidenav-menu"));
expect(element.nativeElement.textContent).toEqual("Example Title");
expect(element.nativeElement.textContent).toEqual("Example Title");
});

it("should toggle expanded on click", () => {
Expand Down
13 changes: 7 additions & 6 deletions src/ui-shell/sidenav/sidenav-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ import { Router } from "@angular/router";
selector: "cds-sidenav-item, ibm-sidenav-item",
template: `
<a *ngIf="!useRouter; else sidenavItemRouterTpl"
class="cds--side-nav__link"
[ngClass]="{
class="cds--side-nav__link"
[ngClass]="{
'cds--side-nav__item--active': active
}"
[href]="href"
[attr.aria-current]="(active ? 'page' : null)"
[attr.title]="title ? title : null"
(click)="navigate($event)">
[href]="href"
[attr.aria-current]="(active ? 'page' : null)"
[attr.title]="title ? title : null"
(click)="navigate($event)">
<ng-template [ngTemplateOutlet]="sidenavItemContentTpl"></ng-template>
</a>

<ng-template #sidenavItemRouterTpl>
<a
[routerLink]="route"
routerLinkActive="cds--side-nav__item--active"
(click)="navigate($event)"
ariaCurrentWhenActive="page"
[attr.title]="title ? title : null"
class="cds--side-nav__link">
Expand Down
Loading