vue-sonner icon indicating copy to clipboard operation
vue-sonner copied to clipboard

BUG: sometimes toasts do not unstack on hover

Open bw1984 opened this issue 1 year ago • 2 comments

Its difficult to show this but sometimes if i trigger toasts in quick succession, they visually stack as expected but then do not 'unstack' when i hover over them. This only seems to happen if they are triggered/created in very quick succession (which can sometimes be difficult to avoid if they are being triggered by background activities which are happening at random intervals)

bw1984 avatar Nov 01 '24 15:11 bw1984

A workaround for this "bug" is to wrap the creation of the toast in a setTimeOut, even with 0ms it fix the bug.

Here a reproduction of the unstack bug with the latest version :

const toastConfig = [
  {
    title: 'warning toast',
    description: 'ceci est une warning',
  },
  {
    title: 'warning toast',
    description: 'ceci est un warning',
  },
];

  for (let i = 0; i < toastConfig.length; i++) {
    const config = toastConfig[i];
      toast.warning(config.title, {
        description: config.description,
      });
  }

If you add a setTimeOut, the unstack works as expected :

  for (let i = 0; i < toastConfig.length; i++) {
    const config = toastConfig[i];
    setTimeout(() => {
      toast.warning(config.title, {
        description: config.description,
      });
    }, 0);
  }

Anyone got an idea of why this is happening ?

CMarzin avatar Dec 04 '24 13:12 CMarzin

Same,I check files' type in a for loop, and got sonners stacked together without spacing, creating a very heavy shadow, while few of the sonners are not fixed in this pile and is displayed normally, unstack normally.

 for (const file of Array.from(files)) {
        console.debug("Adding file:", index++, file);
        if (!fileTypeFilter(file)) {
            toast.warning("不可上传该类型文件", {
                description: file.name,
                id: file.name,
            });
            continue;
        }
…

Image

FallingEpiphany avatar Feb 10 '25 11:02 FallingEpiphany