Skip to content
Merged
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
4 changes: 3 additions & 1 deletion libs/ngx-sonner/src/lib/toast.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ export class ToastComponent implements AfterViewInit, OnDestroy {
effect(() => {
const heightIndex = this.heightIndex();
const toastsHeightBefore = this.toastsHeightBefore();
untracked(() => this.offset.set(heightIndex * GAP + toastsHeightBefore));
untracked(() =>
this.offset.set(Math.round(heightIndex * GAP + toastsHeightBefore))
);
});

effect(() => {
Expand Down
8 changes: 4 additions & 4 deletions libs/ngx-sonner/src/tests/toaster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ describe('Toaster', () => {

it('should show a toast with custom duration', async () => {
const { user, trigger, queryByText, detectChanges } = await setup({
cb: toast => toast('Hello world', { duration: 300 }),
cb: toast => toast('Custom duration', { duration: 300 }),
});

expect(queryByText('Hello world')).toBeNull();
expect(queryByText('Custom duration')).toBeNull();

await user.click(trigger);
expect(queryByText('Hello world')).not.toBeNull();
expect(queryByText('Custom duration')).not.toBeNull();

await sleep(500);
detectChanges();
expect(queryByText('Hello world')).toBeNull();
expect(queryByText('Custom duration')).toBeNull();
});

it('should reset duration on a toast update', async () => {
Expand Down