Skip to content

Commit

Permalink
fix: toast remaining time is handled after render
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkli committed Dec 9, 2024
1 parent bf70b01 commit b19de68
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libs/ngx-sonner/src/lib/toast.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NgComponentOutlet } from '@angular/common';
import {
afterRenderEffect,
AfterViewInit,
ChangeDetectionStrategy,
Component,
Expand All @@ -26,9 +27,9 @@ import { toastState } from './state';
import { ToastProps } from './types';

@Component({
selector: 'ngx-sonner-toast',
imports: [NgComponentOutlet, IsStringPipe, AsComponentPipe],
template: `
selector: 'ngx-sonner-toast',
imports: [NgComponentOutlet, IsStringPipe, AsComponentPipe],
template: `
<li
#toastRef
data-sonner-toast
Expand Down Expand Up @@ -178,7 +179,7 @@ import { ToastProps } from './types';
}
</li>
`,
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ToastComponent implements AfterViewInit, OnDestroy {
protected readonly cn = cn;
Expand Down Expand Up @@ -302,7 +303,7 @@ export class ToastComponent implements AfterViewInit, OnDestroy {
}
});

effect(onCleanup => {
afterRenderEffect(onCleanup => {
if (!this.isPromiseLoadingOrInfiniteDuration()) {
if (this.expanded() || this.interacting()) {
this.pauseTimer();
Expand Down

0 comments on commit b19de68

Please sign in to comment.