diff --git a/projects/kit/components/tabs/tab.directive.ts b/projects/kit/components/tabs/tab.directive.ts index ef7916af3abb..3c972e66e697 100644 --- a/projects/kit/components/tabs/tab.directive.ts +++ b/projects/kit/components/tabs/tab.directive.ts @@ -7,7 +7,7 @@ import {tuiTypedFromEvent} from '@taiga-ui/cdk/observables'; import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom'; import {tuiIsNativeFocused} from '@taiga-ui/cdk/utils/focus'; import {TuiWithIcons} from '@taiga-ui/core/directives/icons'; -import {EMPTY, filter, merge, switchMap} from 'rxjs'; +import {EMPTY, filter, merge, switchMap, take} from 'rxjs'; export const TUI_TAB_ACTIVATE = 'tui-tab-activate'; @@ -35,7 +35,9 @@ export class TuiTab implements OnDestroy { this.el.matches('button') ? tuiTypedFromEvent(this.el, 'click').pipe( // Delaying execution until after all other click callbacks - switchMap(() => tuiTypedFromEvent(this.el.parentElement!, 'click')), + switchMap(() => + tuiTypedFromEvent(this.el.parentElement!, 'click').pipe(take(1)), + ), ) : EMPTY, ) diff --git a/projects/kit/components/tabs/test/tabs.component.spec.ts b/projects/kit/components/tabs/test/tabs.component.spec.ts index f715454a8c1b..76cee523c512 100644 --- a/projects/kit/components/tabs/test/tabs.component.spec.ts +++ b/projects/kit/components/tabs/test/tabs.component.spec.ts @@ -4,14 +4,22 @@ import {ChangeDetectionStrategy, Component, Input, ViewChild} from '@angular/cor import type {ComponentFixture} from '@angular/core/testing'; import {TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; -import {TuiTabs, TuiTabsDirective, TuiTabsHorizontal} from '@taiga-ui/kit'; +import { + TUI_TAB_ACTIVATE, + TuiTabs, + TuiTabsDirective, + TuiTabsHorizontal, +} from '@taiga-ui/kit'; describe('Tabs', () => { @Component({ standalone: true, imports: [AsyncPipe, CommonModule, TuiTabs], template: ` - +