Skip to content

Commit a5e89e2

Browse files
committed
fix: after review
1 parent cdd73d6 commit a5e89e2

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

packages/components/filter-bar/pipes/base-pipe.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
afterNextRender,
33
AfterViewInit,
44
ChangeDetectorRef,
5+
DestroyRef,
56
Directive,
67
ElementRef,
78
inject,
@@ -45,6 +46,8 @@ export abstract class KbqBasePipe<V> implements AfterViewInit {
4546
protected readonly filterBar = inject(KbqFilterBar, { optional: true });
4647
/** @docs-private */
4748
protected readonly changeDetectorRef = inject(ChangeDetectorRef);
49+
/** @docs-private */
50+
protected readonly destroyRef = inject(DestroyRef);
4851

4952
/** values to select from the pipe template */
5053
protected values;

packages/components/filter-bar/pipes/pipe-multi-select.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ViewChildren,
1010
ViewEncapsulation
1111
} from '@angular/core';
12+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
1213
import { FormsModule, ReactiveFormsModule, UntypedFormControl } from '@angular/forms';
1314
import { KbqBadgeModule } from '@koobiq/components/badge';
1415
import { KbqButtonModule } from '@koobiq/components/button';
@@ -115,7 +116,9 @@ export class KbqPipeMultiSelectComponent extends KbqBasePipe<KbqSelectValue[]> i
115116
override ngAfterViewInit() {
116117
super.ngAfterViewInit();
117118

118-
this.select.closedStream.subscribe(() => this.filterBar?.onClosePipe.next(this.data));
119+
this.select.closedStream
120+
.pipe(takeUntilDestroyed(this.destroyRef))
121+
.subscribe(() => this.filterBar?.onClosePipe.next(this.data));
119122
}
120123

121124
/** @docs-private */

packages/components/filter-bar/pipes/pipe-select.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AsyncPipe, NgClass, NgTemplateOutlet } from '@angular/common';
22
import { AfterViewInit, ChangeDetectionStrategy, Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
3+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
34
import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms';
45
import { KbqButtonModule } from '@koobiq/components/button';
56
import { KbqDividerModule } from '@koobiq/components/divider';
@@ -78,7 +79,9 @@ export class KbqPipeSelectComponent extends KbqBasePipe<KbqSelectValue> implemen
7879
override ngAfterViewInit() {
7980
super.ngAfterViewInit();
8081

81-
this.select.closedStream.subscribe(() => this.filterBar?.onClosePipe.next(this.data));
82+
this.select.closedStream
83+
.pipe(takeUntilDestroyed(this.destroyRef))
84+
.subscribe(() => this.filterBar?.onClosePipe.next(this.data));
8285
}
8386

8487
onSelect(item: KbqSelectValue) {

tools/public_api_guard/components/filter-bar.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AfterContentInit } from '@angular/core';
88
import { AfterViewInit } from '@angular/core';
99
import { BehaviorSubject } from 'rxjs';
1010
import { ChangeDetectorRef } from '@angular/core';
11+
import { DestroyRef } from '@angular/core';
1112
import { ElementRef } from '@angular/core';
1213
import { EventEmitter } from '@angular/core';
1314
import { FormControl } from '@angular/forms';
@@ -102,6 +103,7 @@ export abstract class KbqBasePipe<V> implements AfterViewInit {
102103
constructor();
103104
protected readonly changeDetectorRef: ChangeDetectorRef;
104105
readonly data: KbqPipeData<V>;
106+
protected readonly destroyRef: DestroyRef;
105107
protected readonly filterBar: KbqFilterBar | null;
106108
get isEmpty(): boolean;
107109
isMac: boolean;

0 commit comments

Comments
 (0)