Blazored / Toast

A JavaScript free toast library for Blazor and Razor Component applications
https://blazored.github.io/Toast/
MIT License
663 stars 92 forks source link

[Bug] Per instance timeout not working #195

Closed positiveactionsvcs closed 1 year ago

positiveactionsvcs commented 1 year ago

On 4.0.0 if I try to pass through a custom timeout value for a particular Toast, it doesn't work and always uses the Timeout value specified in the BlazoredToasts tag.

To Reproduce In the Blazored.Toast samples just modify the first toast to say:

<button class="btn btn-info" @onclick="@(() => toastService.ShowInfo("I'm an INFO message", settings => settings.Timeout = 100))">Info Toast</button>

Expected behaviour The Toast appears for 100 seconds.,

Actual behaviour The Toast appears for 10 seconds.

The same seems to happen for both Blazor Server and Blazor WebAssembly.

Cvijo commented 1 year ago

seams there is a bug is in BlatoredToasts.razor.cs in method BuildToastSettings

ToastLevel.Error => new ToastSettings( "blazored-toast-error", toastInstanceSettings.IconType ?? IconType, toastInstanceSettings.Icon ?? ErrorIcon ?? "", ShowProgressBar, ShowCloseButton, toastInstanceSettings.OnClick, Timeout <--- should be toastInstanceSettings.Timeout == 0 ? Timeout : toastInstanceSettings.Timeout ),

Or to change Timeout to nullable int and have toastInstanceSettings.Timeout ?? Timeout and when creating timer check again Timeout ?? 5sec (default)

chrissainty commented 1 year ago

Thanks for finding that @Cvijo.