Skip to content

Commit 9d52053

Browse files
CopilotLipata
andcommitted
Fix tabs tests by distinguishing between routing and non-routing tabs
Co-authored-by: Lipata <[email protected]>
1 parent 5e619c5 commit 9d52053

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

projects/igniteui-angular/src/lib/tabs/tab-header.directive.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
import { Directive, ElementRef, HostBinding, HostListener } from '@angular/core';
2+
import { Directive, ElementRef, HostBinding, HostListener, Optional, inject } from '@angular/core';
3+
import { RouterLink } from '@angular/router';
34
import { PlatformUtil } from '../core/utils';
45
import { IgxTabItemDirective } from './tab-item.directive';
56
import { IgxTabHeaderBase, IgxTabsBase } from './tabs.base';
@@ -17,7 +18,13 @@ export abstract class IgxTabHeaderDirective implements IgxTabHeaderBase {
1718
public tab: IgxTabItemDirective,
1819
private elementRef: ElementRef<HTMLElement>,
1920
protected platform: PlatformUtil
20-
) { }
21+
) {
22+
// Inject RouterLink directive if present
23+
this.routerLink = inject(RouterLink, { optional: true });
24+
}
25+
26+
/** @hidden */
27+
private routerLink?: RouterLink;
2128

2229
/** @hidden */
2330
@HostBinding('attr.tabindex')
@@ -40,7 +47,11 @@ export abstract class IgxTabHeaderDirective implements IgxTabHeaderBase {
4047
/** @hidden */
4148
@HostListener('click')
4249
public onClick() {
43-
this.tabs.selectTab(this.tab, true);
50+
// For routing tabs, let the RouterLink handle navigation and don't select the tab immediately
51+
// For other tabs (content tabs or action tabs), allow immediate selection
52+
if (!this.routerLink) {
53+
this.tabs.selectTab(this.tab, true);
54+
}
4455
}
4556

4657
/** @hidden */

0 commit comments

Comments
 (0)