Skip to content

Commit

Permalink
fix: check toast dismissible value in toaster
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkli committed Apr 16, 2024
1 parent 9502c43 commit 31bfc7b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion libs/ngx-sonner/src/lib/toaster.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const GAP = 14;
(mouseenter)="expanded.set(true)"
(mousemove)="expanded.set(true)"
(mouseleave)="handleMouseLeave()"
(pointerdown)="interacting.set(true)"
(pointerdown)="handlePointerDown($event)"
(pointerup)="interacting.set(false)"
[style]="toasterStyles()">
@for (
Expand Down Expand Up @@ -225,12 +225,27 @@ export class NgxSonnerToaster implements OnDestroy {
}

handleFocus(event: FocusEvent) {
const isNotDismissible =
event.target instanceof HTMLElement &&
event.target.dataset['dismissible'] === 'false';

if (isNotDismissible) return;

if (!this.isFocusWithinRef()) {
this.isFocusWithinRef.set(true);
this.lastFocusedElementRef.set(event.relatedTarget as HTMLElement);
}
}

handlePointerDown(event: MouseEvent) {
const isNotDismissible =
event.target instanceof HTMLElement &&
event.target.dataset['dismissible'] === 'false';

if (isNotDismissible) return;
this.interacting.set(true);
}

handleMouseLeave() {
if (!this.interacting()) {
this.expanded.set(false);
Expand Down

0 comments on commit 31bfc7b

Please sign in to comment.