From aef59e04e37adbd91abcd9deafceddbb33a32a76 Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Mon, 18 Sep 2023 14:06:16 +0300 Subject: [PATCH] fix(kit): update a tab when the active index has changed (#5402) --- .../tabs/tabs-with-more/tabs-with-more.component.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/kit/components/tabs/tabs-with-more/tabs-with-more.component.ts b/projects/kit/components/tabs/tabs-with-more/tabs-with-more.component.ts index c670570f8e54..b994f1d0a4aa 100644 --- a/projects/kit/components/tabs/tabs-with-more/tabs-with-more.component.ts +++ b/projects/kit/components/tabs/tabs-with-more/tabs-with-more.component.ts @@ -58,8 +58,11 @@ export class TuiTabsWithMoreComponent implements AfterViewInit { @HostBinding('class._underline') underline = this.options.underline; - @Input() - activeItemIndex = 0; + @Input('activeItemIndex') + set itemIndex(activeItemIndex: number) { + this.activeItemIndex = activeItemIndex; + this.maxIndex = this.getMaxIndex(); + } @Input() itemsLimit = this.options.itemsLimit; @@ -70,6 +73,8 @@ export class TuiTabsWithMoreComponent implements AfterViewInit { @ContentChildren(TuiItemDirective, {read: TemplateRef}) readonly items: QueryList>> = EMPTY_QUERY; + activeItemIndex = 0; + open = false; constructor( @@ -236,8 +241,7 @@ export class TuiTabsWithMoreComponent implements AfterViewInit { } private updateActiveItemIndex(activeItemIndex: number): void { - this.activeItemIndex = activeItemIndex; + this.itemIndex = activeItemIndex; this.activeItemIndexChange.emit(activeItemIndex); - this.maxIndex = this.getMaxIndex(); } }