formaat-design / reshaped

Community repository for storing examples, reporting issues and tracking roadmap
https://reshaped.so
97 stars 3 forks source link

Toast does not hide if hide is called too soon #175

Closed b-graves closed 10 months ago

b-graves commented 10 months ago

We have the following code to show and hide a Toast

const loadingId = toast.show({
      title: '...',
      text: '...',
      color: 'neutral',
      icon: <Loader color="primary" />,
      timeout: 0,
    })
    await dispatch(
      update(something)
    )
    toast.hide(loadingId)

However if the promise rejects immediately then it seems that the hide.toast is missed as the Toast remains

If we add a setTimeout then the toast is hidden, pressumably because following this the Toast has completed being shown so is ready to be hidden:

const loadingId = toast.show({
      title: '...',
      text: '...',
      color: 'neutral',
      icon: <Loader color="primary" />,
      timeout: 0,
    })
    await dispatch(
      update(something)
    )
    setTimeout(() => toast.hide(loadingId), 3000)
blvdmitry commented 10 months ago

Hey, thanks for reporting this, I'll add this to the backlog for the upcoming release

blvdmitry commented 10 months ago

Fixed, coming in the next release