Skip to content

Commit 5ba650c

Browse files
authored
fix: blurry toasts (#6)
* fix: blurry toasts * test: update tests
1 parent fe4a4d1 commit 5ba650c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

libs/ngx-sonner/src/lib/toast.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ export class ToastComponent implements AfterViewInit, OnDestroy {
304304
effect(() => {
305305
const heightIndex = this.heightIndex();
306306
const toastsHeightBefore = this.toastsHeightBefore();
307-
untracked(() => this.offset.set(heightIndex * GAP + toastsHeightBefore));
307+
untracked(() =>
308+
this.offset.set(Math.round(heightIndex * GAP + toastsHeightBefore))
309+
);
308310
});
309311

310312
effect(() => {

libs/ngx-sonner/src/tests/toaster.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ describe('Toaster', () => {
4444

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

50-
expect(queryByText('Hello world')).toBeNull();
50+
expect(queryByText('Custom duration')).toBeNull();
5151

5252
await user.click(trigger);
53-
expect(queryByText('Hello world')).not.toBeNull();
53+
expect(queryByText('Custom duration')).not.toBeNull();
5454

5555
await sleep(500);
5656
detectChanges();
57-
expect(queryByText('Hello world')).toBeNull();
57+
expect(queryByText('Custom duration')).toBeNull();
5858
});
5959

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

0 commit comments

Comments
 (0)