From 7dde6b7d4a6acf377a5235bd794472422b5efce7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 17 Nov 2026 17:01:21 +0800 Subject: [PATCH 1/4] fix(Notifications): handle repeated popup actions Keep Message, Toast, and SweetAlert state consistent across concurrent or repeated actions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Components/Message/Message.razor.cs | 29 +++++++++--- .../Components/Message/Message.razor.js | 34 +++++++------- .../SweetAlert/SweetAlertBody.razor.cs | 44 ++++++++++++------- .../Components/Toast/Toast.razor.js | 20 +++++++-- .../Components/Toast/ToastContainer.razor.cs | 8 +++- .../Extensions/SwalExtensions.cs | 18 +++++++- 6 files changed, 106 insertions(+), 47 deletions(-) diff --git a/src/BootstrapBlazor/Components/Message/Message.razor.cs b/src/BootstrapBlazor/Components/Message/Message.razor.cs index 3deb0b0ceec..0cb13b23618 100644 --- a/src/BootstrapBlazor/Components/Message/Message.razor.cs +++ b/src/BootstrapBlazor/Components/Message/Message.razor.cs @@ -68,7 +68,7 @@ protected override void OnInitialized() private string GetItemId(MessageOption option) => $"{Id}_{option.GetHashCode()}"; - private string? _msgId; + private readonly HashSet _pendingMessages = []; /// /// @@ -76,11 +76,17 @@ protected override void OnInitialized() /// protected override async Task OnAfterRenderAsync(bool firstRender) { + var messages = _pendingMessages.ToArray(); + _pendingMessages.Clear(); + await base.OnAfterRenderAsync(firstRender); - if (!string.IsNullOrEmpty(_msgId)) + foreach (var option in messages) { - await InvokeVoidAsync("show", Id, _msgId); + if (_messages.Contains(option)) + { + await InvokeVoidAsync("show", Id, GetItemId(option)); + } } } @@ -99,13 +105,14 @@ private async Task Show(MessageOption option) if (option.ShowMode == MessageShowMode.Single) { _messages.Clear(); + _pendingMessages.Clear(); } if (!_messages.Contains(option)) { _messages.Add(option); } - _msgId = GetItemId(option); + _pendingMessages.Add(option); await InvokeAsync(StateHasChanged); } @@ -120,6 +127,7 @@ public void Clear(string id) if (option != null) { _messages.Remove(option); + _pendingMessages.Remove(option); } StateHasChanged(); @@ -133,11 +141,18 @@ public void Clear(string id) public async ValueTask Dismiss(string id) { var option = _messages.Find(i => GetItemId(i) == id); - if (option is { OnDismiss: not null }) + if (option == null) + { + return; + } + + _messages.Remove(option); + _pendingMessages.Remove(option); + await InvokeAsync(StateHasChanged); + + if (option.OnDismiss != null) { await option.OnDismiss(); - _messages.Remove(option); - StateHasChanged(); } } diff --git a/src/BootstrapBlazor/Components/Message/Message.razor.js b/src/BootstrapBlazor/Components/Message/Message.razor.js index 8429a614422..34cd02f3920 100644 --- a/src/BootstrapBlazor/Components/Message/Message.razor.js +++ b/src/BootstrapBlazor/Components/Message/Message.razor.js @@ -24,6 +24,21 @@ export function show(id, msgId) { return; } + const close = method => { + if (!msg.items.includes(msgItem)) { + return; + } + + if (msgItem.animationId) { + cancelAnimationFrame(msgItem.animationId); + msgItem.animationId = null; + } + EventHandler.off(el, 'click'); + el.classList.add("d-none"); + msg.items = msg.items.filter(i => i !== msgItem); + return msg.invoke.invokeMethodAsync(method, msgId); + }; + const autoHide = el.getAttribute('data-bb-autohide') === 'true'; if (autoHide) { const delay = parseInt(el.getAttribute('data-bb-delay')); @@ -35,7 +50,7 @@ export function show(id, msgId) { const elapsed = ts - start; if (elapsed > delay) { - close(); + close("Clear"); } else { msgItem.animationId = requestAnimationFrame(autoCloseAnimation); @@ -45,26 +60,11 @@ export function show(id, msgId) { } el.classList.add('show'); - const close = () => { - el.classList.add("d-none"); - - msg.items = msg.items.filter(i => i.el.id !== msgId); - msg.invoke.invokeMethodAsync("Clear", msgId); - }; - EventHandler.on(el, 'click', '.btn-close', async e => { e.preventDefault(); e.stopPropagation(); - const alert = e.delegateTarget.closest('.alert'); - if (alert) { - EventHandler.off(el, 'click') - alert.classList.add("d-none"); - - const alertId = alert.getAttribute('id'); - msg.items = msg.items.filter(i => i.el.id !== alertId); - await msg.invoke.invokeMethodAsync('Dismiss', alertId); - } + await close('Dismiss'); }); } diff --git a/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs b/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs index 443a26ffe0c..3cf47206669 100644 --- a/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs +++ b/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs @@ -174,29 +174,41 @@ protected override void OnParametersSet() ConfirmButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.SweetAlertConfirmIcon); } - private async Task OnClickClose() - { - if (OnCloseAsync != null) - { - await OnCloseAsync(); - } + private bool _isClosing; - if (CloseModal != null) - { - await CloseModal(); - } - } + private bool _actionCompleted; + + private Task OnClickClose() => CloseAsync(OnCloseAsync); + + private Task OnClickConfirm() => CloseAsync(OnConfirmAsync); - private async Task OnClickConfirm() + private async Task CloseAsync(Func? callback) { - if (OnConfirmAsync != null) + if (_isClosing) { - await OnConfirmAsync(); + return; } - if (CloseModal != null) + _isClosing = true; + try + { + if (!_actionCompleted) + { + if (callback != null) + { + await callback(); + } + _actionCompleted = true; + } + + if (CloseModal != null) + { + await CloseModal(); + } + } + finally { - await CloseModal(); + _isClosing = false; } } } diff --git a/src/BootstrapBlazor/Components/Toast/Toast.razor.js b/src/BootstrapBlazor/Components/Toast/Toast.razor.js index 79be9cfe0db..10ad7ca03e1 100644 --- a/src/BootstrapBlazor/Components/Toast/Toast.razor.js +++ b/src/BootstrapBlazor/Components/Toast/Toast.razor.js @@ -1,4 +1,4 @@ -import Data from "../../modules/data.js" +import Data from "../../modules/data.js" import EventHandler from "../../modules/event-handler.js" export function init(id, invoke, callback) { @@ -12,7 +12,9 @@ export function init(id, invoke, callback) { showProgress: () => { return toast.toast._config.autohide }, - progressElement + progressElement, + closing: false, + closed: false } Data.set(id, toast); @@ -26,8 +28,19 @@ export function init(id, invoke, callback) { progressElement.style.width = '100%' } }) + EventHandler.on(el, 'hide.bs.toast', e => { + if (toast.closing) { + e.preventDefault(); + } + else { + toast.closing = true; + } + }) EventHandler.on(el, 'hidden.bs.toast', () => { - invoke.invokeMethodAsync(toast.callback) + if (!toast.closed) { + toast.closed = true; + invoke.invokeMethodAsync(toast.callback) + } }) EventHandler.on(progressElement, 'transitionend', e => { if (toast.toast._config.autohide === false) { @@ -62,6 +75,7 @@ export function dispose(id) { const { element, progressElement } = toast; EventHandler.off(element, 'shown.bs.toast'); + EventHandler.off(element, 'hide.bs.toast'); EventHandler.off(element, 'hidden.bs.toast'); EventHandler.off(progressElement, 'transitionend'); diff --git a/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs b/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs index 1b0683098e5..07fb1defc08 100644 --- a/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs +++ b/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs @@ -82,12 +82,16 @@ private async Task Show(ToastOption option) /// public async Task Close(ToastOption option) { + if (!Toasts.Remove(option)) + { + return; + } + + StateHasChanged(); if (option.OnCloseAsync != null) { await option.OnCloseAsync(); } - Toasts.Remove(option); - StateHasChanged(); } /// diff --git a/src/BootstrapBlazor/Extensions/SwalExtensions.cs b/src/BootstrapBlazor/Extensions/SwalExtensions.cs index b68b9f4634b..3e82e99fe91 100644 --- a/src/BootstrapBlazor/Extensions/SwalExtensions.cs +++ b/src/BootstrapBlazor/Extensions/SwalExtensions.cs @@ -14,15 +14,29 @@ public static class SwalExtensions /// /// 异步回调方法 /// 异步callback method + /// 已有弹窗显示时忽略新请求并返回 false。 + /// Ignores a new request and returns false while a popup is already displayed. /// /// /// /// 指定弹窗组件 默认为 null 使用 组件内置弹窗组件指定弹窗component default is为 null 使用 component内置弹窗component public static async Task ShowModal(this SwalService service, SwalOption option, SweetAlert? swal = null) { + var isConfirm = option.IsConfirm; option.IsConfirm = true; - await service.Show(option, swal); - return await option.ConfirmContext.ConfirmTask.Task; + var previousContext = option.ConfirmContext; + // An accepted request assigns its context before awaiting rendering. + var showTask = service.Show(option, swal); + var context = option.ConfirmContext; + await showTask; + + if (context == null || context == previousContext) + { + option.IsConfirm = isConfirm; + return false; + } + + return await context.ConfirmTask.Task; } /// From 3c7f7db2d5b9a170ba8278317df9ce1c027b7dc4 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 17 Nov 2026 17:04:14 +0800 Subject: [PATCH 2/4] Revert "fix(Notifications): handle repeated popup actions" This reverts commit 7dde6b7d4a6acf377a5235bd794472422b5efce7. --- .../Components/Message/Message.razor.cs | 29 +++--------- .../Components/Message/Message.razor.js | 34 +++++++------- .../SweetAlert/SweetAlertBody.razor.cs | 44 +++++++------------ .../Components/Toast/Toast.razor.js | 20 ++------- .../Components/Toast/ToastContainer.razor.cs | 8 +--- .../Extensions/SwalExtensions.cs | 18 +------- 6 files changed, 47 insertions(+), 106 deletions(-) diff --git a/src/BootstrapBlazor/Components/Message/Message.razor.cs b/src/BootstrapBlazor/Components/Message/Message.razor.cs index 0cb13b23618..3deb0b0ceec 100644 --- a/src/BootstrapBlazor/Components/Message/Message.razor.cs +++ b/src/BootstrapBlazor/Components/Message/Message.razor.cs @@ -68,7 +68,7 @@ protected override void OnInitialized() private string GetItemId(MessageOption option) => $"{Id}_{option.GetHashCode()}"; - private readonly HashSet _pendingMessages = []; + private string? _msgId; /// /// @@ -76,17 +76,11 @@ protected override void OnInitialized() /// protected override async Task OnAfterRenderAsync(bool firstRender) { - var messages = _pendingMessages.ToArray(); - _pendingMessages.Clear(); - await base.OnAfterRenderAsync(firstRender); - foreach (var option in messages) + if (!string.IsNullOrEmpty(_msgId)) { - if (_messages.Contains(option)) - { - await InvokeVoidAsync("show", Id, GetItemId(option)); - } + await InvokeVoidAsync("show", Id, _msgId); } } @@ -105,14 +99,13 @@ private async Task Show(MessageOption option) if (option.ShowMode == MessageShowMode.Single) { _messages.Clear(); - _pendingMessages.Clear(); } if (!_messages.Contains(option)) { _messages.Add(option); } - _pendingMessages.Add(option); + _msgId = GetItemId(option); await InvokeAsync(StateHasChanged); } @@ -127,7 +120,6 @@ public void Clear(string id) if (option != null) { _messages.Remove(option); - _pendingMessages.Remove(option); } StateHasChanged(); @@ -141,18 +133,11 @@ public void Clear(string id) public async ValueTask Dismiss(string id) { var option = _messages.Find(i => GetItemId(i) == id); - if (option == null) - { - return; - } - - _messages.Remove(option); - _pendingMessages.Remove(option); - await InvokeAsync(StateHasChanged); - - if (option.OnDismiss != null) + if (option is { OnDismiss: not null }) { await option.OnDismiss(); + _messages.Remove(option); + StateHasChanged(); } } diff --git a/src/BootstrapBlazor/Components/Message/Message.razor.js b/src/BootstrapBlazor/Components/Message/Message.razor.js index 34cd02f3920..8429a614422 100644 --- a/src/BootstrapBlazor/Components/Message/Message.razor.js +++ b/src/BootstrapBlazor/Components/Message/Message.razor.js @@ -24,21 +24,6 @@ export function show(id, msgId) { return; } - const close = method => { - if (!msg.items.includes(msgItem)) { - return; - } - - if (msgItem.animationId) { - cancelAnimationFrame(msgItem.animationId); - msgItem.animationId = null; - } - EventHandler.off(el, 'click'); - el.classList.add("d-none"); - msg.items = msg.items.filter(i => i !== msgItem); - return msg.invoke.invokeMethodAsync(method, msgId); - }; - const autoHide = el.getAttribute('data-bb-autohide') === 'true'; if (autoHide) { const delay = parseInt(el.getAttribute('data-bb-delay')); @@ -50,7 +35,7 @@ export function show(id, msgId) { const elapsed = ts - start; if (elapsed > delay) { - close("Clear"); + close(); } else { msgItem.animationId = requestAnimationFrame(autoCloseAnimation); @@ -60,11 +45,26 @@ export function show(id, msgId) { } el.classList.add('show'); + const close = () => { + el.classList.add("d-none"); + + msg.items = msg.items.filter(i => i.el.id !== msgId); + msg.invoke.invokeMethodAsync("Clear", msgId); + }; + EventHandler.on(el, 'click', '.btn-close', async e => { e.preventDefault(); e.stopPropagation(); - await close('Dismiss'); + const alert = e.delegateTarget.closest('.alert'); + if (alert) { + EventHandler.off(el, 'click') + alert.classList.add("d-none"); + + const alertId = alert.getAttribute('id'); + msg.items = msg.items.filter(i => i.el.id !== alertId); + await msg.invoke.invokeMethodAsync('Dismiss', alertId); + } }); } diff --git a/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs b/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs index 3cf47206669..443a26ffe0c 100644 --- a/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs +++ b/src/BootstrapBlazor/Components/SweetAlert/SweetAlertBody.razor.cs @@ -174,41 +174,29 @@ protected override void OnParametersSet() ConfirmButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.SweetAlertConfirmIcon); } - private bool _isClosing; - - private bool _actionCompleted; - - private Task OnClickClose() => CloseAsync(OnCloseAsync); - - private Task OnClickConfirm() => CloseAsync(OnConfirmAsync); - - private async Task CloseAsync(Func? callback) + private async Task OnClickClose() { - if (_isClosing) + if (OnCloseAsync != null) + { + await OnCloseAsync(); + } + + if (CloseModal != null) { - return; + await CloseModal(); } + } - _isClosing = true; - try + private async Task OnClickConfirm() + { + if (OnConfirmAsync != null) { - if (!_actionCompleted) - { - if (callback != null) - { - await callback(); - } - _actionCompleted = true; - } - - if (CloseModal != null) - { - await CloseModal(); - } + await OnConfirmAsync(); } - finally + + if (CloseModal != null) { - _isClosing = false; + await CloseModal(); } } } diff --git a/src/BootstrapBlazor/Components/Toast/Toast.razor.js b/src/BootstrapBlazor/Components/Toast/Toast.razor.js index 10ad7ca03e1..79be9cfe0db 100644 --- a/src/BootstrapBlazor/Components/Toast/Toast.razor.js +++ b/src/BootstrapBlazor/Components/Toast/Toast.razor.js @@ -1,4 +1,4 @@ -import Data from "../../modules/data.js" +import Data from "../../modules/data.js" import EventHandler from "../../modules/event-handler.js" export function init(id, invoke, callback) { @@ -12,9 +12,7 @@ export function init(id, invoke, callback) { showProgress: () => { return toast.toast._config.autohide }, - progressElement, - closing: false, - closed: false + progressElement } Data.set(id, toast); @@ -28,19 +26,8 @@ export function init(id, invoke, callback) { progressElement.style.width = '100%' } }) - EventHandler.on(el, 'hide.bs.toast', e => { - if (toast.closing) { - e.preventDefault(); - } - else { - toast.closing = true; - } - }) EventHandler.on(el, 'hidden.bs.toast', () => { - if (!toast.closed) { - toast.closed = true; - invoke.invokeMethodAsync(toast.callback) - } + invoke.invokeMethodAsync(toast.callback) }) EventHandler.on(progressElement, 'transitionend', e => { if (toast.toast._config.autohide === false) { @@ -75,7 +62,6 @@ export function dispose(id) { const { element, progressElement } = toast; EventHandler.off(element, 'shown.bs.toast'); - EventHandler.off(element, 'hide.bs.toast'); EventHandler.off(element, 'hidden.bs.toast'); EventHandler.off(progressElement, 'transitionend'); diff --git a/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs b/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs index 07fb1defc08..1b0683098e5 100644 --- a/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs +++ b/src/BootstrapBlazor/Components/Toast/ToastContainer.razor.cs @@ -82,16 +82,12 @@ private async Task Show(ToastOption option) /// public async Task Close(ToastOption option) { - if (!Toasts.Remove(option)) - { - return; - } - - StateHasChanged(); if (option.OnCloseAsync != null) { await option.OnCloseAsync(); } + Toasts.Remove(option); + StateHasChanged(); } /// diff --git a/src/BootstrapBlazor/Extensions/SwalExtensions.cs b/src/BootstrapBlazor/Extensions/SwalExtensions.cs index 3e82e99fe91..b68b9f4634b 100644 --- a/src/BootstrapBlazor/Extensions/SwalExtensions.cs +++ b/src/BootstrapBlazor/Extensions/SwalExtensions.cs @@ -14,29 +14,15 @@ public static class SwalExtensions /// /// 异步回调方法 /// 异步callback method - /// 已有弹窗显示时忽略新请求并返回 false。 - /// Ignores a new request and returns false while a popup is already displayed. /// /// /// /// 指定弹窗组件 默认为 null 使用 组件内置弹窗组件指定弹窗component default is为 null 使用 component内置弹窗component public static async Task ShowModal(this SwalService service, SwalOption option, SweetAlert? swal = null) { - var isConfirm = option.IsConfirm; option.IsConfirm = true; - var previousContext = option.ConfirmContext; - // An accepted request assigns its context before awaiting rendering. - var showTask = service.Show(option, swal); - var context = option.ConfirmContext; - await showTask; - - if (context == null || context == previousContext) - { - option.IsConfirm = isConfirm; - return false; - } - - return await context.ConfirmTask.Task; + await service.Show(option, swal); + return await option.ConfirmContext.ConfirmTask.Task; } /// From 76153798602537164307ae62fa8e9e54f495d0a4 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 17 Nov 2026 17:03:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20=E6=8F=90=E4=BA=A4=20Message=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Message/Message.razor.cs | 29 ++++++++++++---- .../Components/Message/Message.razor.js | 34 +++++++++---------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/BootstrapBlazor/Components/Message/Message.razor.cs b/src/BootstrapBlazor/Components/Message/Message.razor.cs index 3deb0b0ceec..0cb13b23618 100644 --- a/src/BootstrapBlazor/Components/Message/Message.razor.cs +++ b/src/BootstrapBlazor/Components/Message/Message.razor.cs @@ -68,7 +68,7 @@ protected override void OnInitialized() private string GetItemId(MessageOption option) => $"{Id}_{option.GetHashCode()}"; - private string? _msgId; + private readonly HashSet _pendingMessages = []; /// /// @@ -76,11 +76,17 @@ protected override void OnInitialized() /// protected override async Task OnAfterRenderAsync(bool firstRender) { + var messages = _pendingMessages.ToArray(); + _pendingMessages.Clear(); + await base.OnAfterRenderAsync(firstRender); - if (!string.IsNullOrEmpty(_msgId)) + foreach (var option in messages) { - await InvokeVoidAsync("show", Id, _msgId); + if (_messages.Contains(option)) + { + await InvokeVoidAsync("show", Id, GetItemId(option)); + } } } @@ -99,13 +105,14 @@ private async Task Show(MessageOption option) if (option.ShowMode == MessageShowMode.Single) { _messages.Clear(); + _pendingMessages.Clear(); } if (!_messages.Contains(option)) { _messages.Add(option); } - _msgId = GetItemId(option); + _pendingMessages.Add(option); await InvokeAsync(StateHasChanged); } @@ -120,6 +127,7 @@ public void Clear(string id) if (option != null) { _messages.Remove(option); + _pendingMessages.Remove(option); } StateHasChanged(); @@ -133,11 +141,18 @@ public void Clear(string id) public async ValueTask Dismiss(string id) { var option = _messages.Find(i => GetItemId(i) == id); - if (option is { OnDismiss: not null }) + if (option == null) + { + return; + } + + _messages.Remove(option); + _pendingMessages.Remove(option); + await InvokeAsync(StateHasChanged); + + if (option.OnDismiss != null) { await option.OnDismiss(); - _messages.Remove(option); - StateHasChanged(); } } diff --git a/src/BootstrapBlazor/Components/Message/Message.razor.js b/src/BootstrapBlazor/Components/Message/Message.razor.js index 8429a614422..34cd02f3920 100644 --- a/src/BootstrapBlazor/Components/Message/Message.razor.js +++ b/src/BootstrapBlazor/Components/Message/Message.razor.js @@ -24,6 +24,21 @@ export function show(id, msgId) { return; } + const close = method => { + if (!msg.items.includes(msgItem)) { + return; + } + + if (msgItem.animationId) { + cancelAnimationFrame(msgItem.animationId); + msgItem.animationId = null; + } + EventHandler.off(el, 'click'); + el.classList.add("d-none"); + msg.items = msg.items.filter(i => i !== msgItem); + return msg.invoke.invokeMethodAsync(method, msgId); + }; + const autoHide = el.getAttribute('data-bb-autohide') === 'true'; if (autoHide) { const delay = parseInt(el.getAttribute('data-bb-delay')); @@ -35,7 +50,7 @@ export function show(id, msgId) { const elapsed = ts - start; if (elapsed > delay) { - close(); + close("Clear"); } else { msgItem.animationId = requestAnimationFrame(autoCloseAnimation); @@ -45,26 +60,11 @@ export function show(id, msgId) { } el.classList.add('show'); - const close = () => { - el.classList.add("d-none"); - - msg.items = msg.items.filter(i => i.el.id !== msgId); - msg.invoke.invokeMethodAsync("Clear", msgId); - }; - EventHandler.on(el, 'click', '.btn-close', async e => { e.preventDefault(); e.stopPropagation(); - const alert = e.delegateTarget.closest('.alert'); - if (alert) { - EventHandler.off(el, 'click') - alert.classList.add("d-none"); - - const alertId = alert.getAttribute('id'); - msg.items = msg.items.filter(i => i.el.id !== alertId); - await msg.invoke.invokeMethodAsync('Dismiss', alertId); - } + await close('Dismiss'); }); } From a159c460b88bcb6dbde17effb2c63f781d382319 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 17 Nov 2026 17:13:21 +0800 Subject: [PATCH 4/4] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/MessageTest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/UnitTest/Components/MessageTest.cs b/test/UnitTest/Components/MessageTest.cs index 4cfd18a6690..f5a827877a1 100644 --- a/test/UnitTest/Components/MessageTest.cs +++ b/test/UnitTest/Components/MessageTest.cs @@ -95,9 +95,10 @@ await cut.InvokeAsync(() => service.Show(new MessageOption() Assert.NotNull(alert); Assert.NotNull(alert.Id); - await cut.Instance.Dismiss(alert.Id); + var alertId = alert.Id; + await cut.Instance.Dismiss(alertId); await cut.Instance.Dismiss("test_id"); - await cut.InvokeAsync(() => cut.Instance.Clear(alert.Id)); + await cut.InvokeAsync(() => cut.Instance.Clear(alertId)); await cut.InvokeAsync(() => service.Show(new MessageOption() {