From 807862091cac6b35d5a8b303d2ab7a6a946f4b59 Mon Sep 17 00:00:00 2001 From: Clara Castillo Date: Mon, 1 Apr 2024 13:16:25 +0200 Subject: [PATCH 1/2] fix: blurry toasts --- libs/ngx-sonner/src/lib/toast.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/ngx-sonner/src/lib/toast.component.ts b/libs/ngx-sonner/src/lib/toast.component.ts index 599660f..93d0555 100644 --- a/libs/ngx-sonner/src/lib/toast.component.ts +++ b/libs/ngx-sonner/src/lib/toast.component.ts @@ -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(() => { From ce3a882d548e8541cdc471e51b49988f7907c381 Mon Sep 17 00:00:00 2001 From: Clara Castillo Date: Mon, 1 Apr 2024 13:45:43 +0200 Subject: [PATCH 2/2] test: update tests --- libs/ngx-sonner/src/tests/toaster.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/ngx-sonner/src/tests/toaster.spec.ts b/libs/ngx-sonner/src/tests/toaster.spec.ts index b285b47..3464d67 100644 --- a/libs/ngx-sonner/src/tests/toaster.spec.ts +++ b/libs/ngx-sonner/src/tests/toaster.spec.ts @@ -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 () => {