Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix possible memory leak #6963

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export class TuiRippleDirective {
const touchEnd$ = tuiTypedFromEvent(this.el, 'touchend');
const touchMove$ = tuiTypedFromEvent(this.el, 'touchmove');

this.end$.subscribe(element => this.renderer.removeChild(this.el, element));
this.end$
.pipe(takeUntil(this.destroy$))
Comment on lines +41 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.subscribe(element => this.renderer.removeChild(this.el, element));

this.start$
.pipe(
Expand Down
10 changes: 6 additions & 4 deletions projects/core/components/link/link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import {MODE_PROVIDER} from '@taiga-ui/core/providers';
import {TUI_MODE} from '@taiga-ui/core/tokens';
import type {TuiHorizontalDirection} from '@taiga-ui/core/types';
import {map, merge} from 'rxjs';
import {map, merge, takeUntil} from 'rxjs';

// @bad TODO: Think about extending Interactive
@Component({
Expand Down Expand Up @@ -70,9 +70,11 @@ export class TuiLinkComponent implements TuiFocusableElementAccessor {
protected readonly mode$ = inject(TUI_MODE);

constructor() {
inject(TuiFocusVisibleService).subscribe(visible => {
this.focusVisible = visible;
});
inject(TuiFocusVisibleService)
.pipe(takeUntil(inject(TuiDestroyService, {self: true})))
Comment on lines +73 to +74
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

takeUntil(inject(TuiDestroyService, {self: true})),

.subscribe(visible => {
this.focusVisible = visible;
});
}

public get nativeFocusableElement(): TuiNativeFocusableElement {
Expand Down
7 changes: 4 additions & 3 deletions projects/kit/components/action/action.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TuiFocusVisibleService,
tuiIsNativeFocused,
} from '@taiga-ui/cdk';
import {takeUntil} from 'rxjs';

@Component({
selector: 'button[tuiAction], a[tuiAction]',
Expand All @@ -41,9 +42,9 @@ export class TuiActionComponent extends AbstractTuiInteractive {
constructor() {
super();

inject(TuiFocusVisibleService).subscribe(visible => {
this.updateFocusVisible(visible);
});
inject(TuiFocusVisibleService)
.pipe(takeUntil(inject(TuiDestroyService, {self: true})))
.subscribe(visible => this.updateFocusVisible(visible));
}

public get nativeFocusableElement(): TuiNativeFocusableElement | null {
Expand Down
17 changes: 10 additions & 7 deletions projects/kit/components/stepper/step/step.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {RouterLinkActive} from '@angular/router';
import {TuiDestroyService, TuiFocusVisibleService} from '@taiga-ui/cdk';
import {TUI_COMMON_ICONS} from '@taiga-ui/core';
import type {Observable} from 'rxjs';
import {EMPTY, filter} from 'rxjs';
import {EMPTY, filter, takeUntil} from 'rxjs';

import {TuiStepperComponent} from '../stepper.component';

Expand Down Expand Up @@ -46,13 +46,16 @@ export class TuiStepComponent {
protected readonly icons = inject(TUI_COMMON_ICONS);

constructor() {
this.routerLinkActive$.pipe(filter(Boolean)).subscribe(() => {
this.activate();
});
this.routerLinkActive$
.pipe(filter(Boolean))
.pipe(takeUntil(inject(TuiDestroyService, {self: true})))
.subscribe(() => this.activate());

this.focusVisible$.subscribe(visible => {
this.focusVisible = visible;
});
this.focusVisible$
.pipe(takeUntil(inject(TuiDestroyService, {self: true})))
.subscribe(visible => {
this.focusVisible = visible;
});
}

@HostBinding('class._active')
Expand Down
Loading