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' ;
34import { PlatformUtil } from '../core/utils' ;
45import { IgxTabItemDirective } from './tab-item.directive' ;
56import { 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