emilkowalski / sonner

An opinionated toast component for React.

Home Page:https://sonner.emilkowal.ski

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Toasts infinite loop when hovering closeButton

nigellima opened this issue Β· comments

Describe the feature / bug πŸ“:

There is a point in the screen which the the toasts with closeButton get into an infinite loop between expand/default appearance when hovering the close button

toast-sonner

Steps to reproduce the bug πŸ”:

  1. Open a few toasts with closeButton
  2. Hover the close button and move the mouse to the left

I had the same problem with a button positioned on the top-right, in the same position where the toast will render

This happens in my case too. This is caused since The mouse gets near to the container that triggers the OnMouseEnter and onMouseLeave again and again.
Can be resolved using a small hack by having a small time gap between expand and collapse.

[data-sonner-toast][data-expanded='false'][data-front='false'] {
    height: auto;
    animation: changeHeight 0s ease-in-out 150ms forwards; 
}

@keyframes changeHeight {
    0% {
        height: 0px 
    }
    100% {
        height: var(--front-toast-height)
    }
}