diff --git a/src/BootstrapBlazor/Components/Message/MessageService.cs b/src/BootstrapBlazor/Components/Message/MessageService.cs index 3b4d8047d4a..663ff3e9062 100644 --- a/src/BootstrapBlazor/Components/Message/MessageService.cs +++ b/src/BootstrapBlazor/Components/Message/MessageService.cs @@ -22,7 +22,7 @@ public async Task Show(MessageOption option, Message? message = null) { if (!option.ForceDelay) { - if (Options.MessageDelay != 0) + if (Options.MessageDelay > 0) { option.Delay = Options.MessageDelay; } diff --git a/src/BootstrapBlazor/Components/SweetAlert/SwalService.cs b/src/BootstrapBlazor/Components/SweetAlert/SwalService.cs index 04ad180549e..f1ef9f802bb 100644 --- a/src/BootstrapBlazor/Components/SweetAlert/SwalService.cs +++ b/src/BootstrapBlazor/Components/SweetAlert/SwalService.cs @@ -17,7 +17,7 @@ public class SwalService(IOptionsMonitor options) : Boot /// 指定弹窗组件 默认为 null 使用 组件内置弹窗组件 public async Task Show(SwalOption option, SweetAlert? swal = null) { - if (!option.ForceDelay && options.CurrentValue.SwalDelay != 0) + if (!option.ForceDelay && options.CurrentValue.SwalDelay > 0) { option.Delay = options.CurrentValue.SwalDelay; } diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs index 01369ba40cc..125dd496f77 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs @@ -1153,11 +1153,18 @@ private async Task ExecuteExportAsync(Func> callback) } } - private ToastOption GetToastOption(string title) => new() + private ToastOption GetToastOption(string title) { - Title = title, - Delay = Options.CurrentValue.ToastDelay - }; + var option = new ToastOption() + { + Title = title, + }; + if (Options.CurrentValue.ToastDelay > 0) + { + option.Delay = Options.CurrentValue.ToastDelay; + } + return option; + } private Task ExportAsync() => ExecuteExportAsync(() => OnExportAsync != null ? OnExportAsync(new TableExportDataContext(TableExportType.Unknown, Rows, GetVisibleColumns(), BuildQueryPageOptions())) diff --git a/test/UnitTest/Components/TableDialogTest.cs b/test/UnitTest/Components/TableDialogTest.cs index 4b6f6cc0828..64869dfadad 100644 --- a/test/UnitTest/Components/TableDialogTest.cs +++ b/test/UnitTest/Components/TableDialogTest.cs @@ -6,6 +6,7 @@ using AngleSharp.Dom; using Microsoft.AspNetCore.Components.Web; using Microsoft.Extensions.Localization; +using Microsoft.Extensions.Options; using System.Reflection; namespace UnitTest.Components; @@ -15,6 +16,8 @@ public class TableDialogTest : TableDialogTestBase [Fact] public async Task EditAsync_Ok() { + var options = Context.Services.GetRequiredService>(); + options.CurrentValue.ToastDelay = 0; var localizer = Context.Services.GetRequiredService>(); var items = Foo.GenerateFoo(localizer, 2); var cut = Context.RenderComponent(pb =>