Skip to content

Commit

Permalink
fix: blurry toasts (#6)
Browse files Browse the repository at this point in the history
* fix: blurry toasts

* test: update tests
  • Loading branch information
tutkli committed Apr 1, 2024
1 parent fe4a4d1 commit 5ba650c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit 5ba650c

Please sign in to comment.