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

Issue when creating multiple toasts in a loop

Open vikramsoni2 opened this issue 1 year ago • 4 comments

try to run 3 toasts in a loop.

it just shows one toast and the other toasts are in html but behind the first toast, and it does not expand on hover. the first toast just moves a little bit when hovered.

vikramsoni2 avatar Jun 18 '24 10:06 vikramsoni2

I also have the same issue.

that-ambuj avatar Jul 02 '24 13:07 that-ambuj

Use setTimeout to add interval between them. e.g.

const sleep = ms => new Promise(r => setTimeout(r, ms))
const addToasts = async (items) => {
  for (const item of items) {
    addToast(item)
    await sleep(1)
  }
}

ronaldemo avatar Sep 02 '24 07:09 ronaldemo

any ideas on how this can be fixed without the timeout hack? i have the same issue and i'm showing potentially 1000s of toasts in quick succession. Adding a timeout will cause too much delay

bw1984 avatar Nov 04 '24 20:11 bw1984

Use setTimeout to add interval between them. e.g.

const sleep = ms => new Promise(r => setTimeout(r, ms))
const addToasts = async (items) => {
  for (const item of items) {
    addToast(item)
    await sleep(1)
  }
}

Just as i was about to quit on this ...helped my thinking

kevinwaxi avatar Jun 01 '25 07:06 kevinwaxi