solid-toast icon indicating copy to clipboard operation
solid-toast copied to clipboard

Loading Toast dismisses automatically, if toaster sets default

Open JulianFlicker opened this issue 2 years ago • 3 comments

If the Toaster configures a default duration, then toasts created with toast.loading ignore will use the default duration, instead of Infinity, like it should

<Toaster position="top-center" toastOptions={{ duration:5000 }} />

toast.loading("Message")

Expected result: the loading toast should stay there indefinitely Actual result: the loading toast disappears after the default duration

JulianFlicker avatar Jan 25 '23 14:01 JulianFlicker

This is expected behavior 😄 You can pass overriding configs by using toast.loading("Message", {duration: Infinity}). Maybe we can add a default options on the Toaster component as well per toast style.

ardeora avatar Jan 26 '23 22:01 ardeora

This default behavior destroys toast.loading() as well as toast.promise(). As most users would expect the loading state to stay there as long as the toast is not yet successfull/errored or the promise resolved/rejected, maybe split the toasterOptions.duration on the Toaster to duration and loadingDuration, as otherwise this would very easily introduce bugs, as this is only noticeable if the promise takes longer to resolve than the set default duration.

Also overriding the duration for each toast.loading isn't possible currently, as toast.promise uses toast.loading internally, and it reuses the options for loading, success and error, therefore if i would pass in {duration:Infinity} to this function, the success and error would stay there infinitely as well.

JulianFlicker avatar Jan 27 '23 06:01 JulianFlicker

I'll take a look at this

ardeora avatar Jan 27 '23 19:01 ardeora