From 7d1acc03ceeafe48cbe5e53bf3f76abb58654a25 Mon Sep 17 00:00:00 2001
From: tangzhiming <657345471@qq.com>
Date: Mon, 4 Jul 2022 17:22:12 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0TableCellButton=E9=87=8A?=
=?UTF-8?q?=E6=94=BE=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Components/Table/TableCellButton.cs | 11 +++++++++++
.../Components/Table/TableCellPopconfirmButton.cs | 11 +++++++++++
.../Components/Table/TableExtensionButton.razor.cs | 5 +++++
test/UnitTest/Components/TableTest.cs | 11 +++++++++++
4 files changed, 38 insertions(+)
diff --git a/src/BootstrapBlazor/Components/Table/TableCellButton.cs b/src/BootstrapBlazor/Components/Table/TableCellButton.cs
index 2bc81b1ec..962b294be 100644
--- a/src/BootstrapBlazor/Components/Table/TableCellButton.cs
+++ b/src/BootstrapBlazor/Components/Table/TableCellButton.cs
@@ -48,4 +48,15 @@ public class TableCellButton : ButtonBase
Size = Size.ExtraSmall;
}
}
+
+ ///
+ /// DisposeAsyncCore
+ ///
+ ///
+ ///
+ protected override ValueTask DisposeAsyncCore(bool disposing)
+ {
+ Buttons?.RemoveButton(this);
+ return base.DisposeAsyncCore(disposing);
+ }
}
diff --git a/src/BootstrapBlazor/Components/Table/TableCellPopconfirmButton.cs b/src/BootstrapBlazor/Components/Table/TableCellPopconfirmButton.cs
index e1506bb9e..39ad5150a 100644
--- a/src/BootstrapBlazor/Components/Table/TableCellPopconfirmButton.cs
+++ b/src/BootstrapBlazor/Components/Table/TableCellPopconfirmButton.cs
@@ -58,4 +58,15 @@ public class TableCellPopconfirmButton : PopConfirmButtonBase
CloseButtonText ??= Localizer[nameof(CloseButtonText)];
Content ??= Localizer[nameof(Content)];
}
+
+ ///
+ /// DisposeAsyncCore
+ ///
+ ///
+ ///
+ protected override ValueTask DisposeAsyncCore(bool disposing)
+ {
+ Buttons?.RemoveButton(this);
+ return base.DisposeAsyncCore(disposing);
+ }
}
diff --git a/src/BootstrapBlazor/Components/Table/TableExtensionButton.razor.cs b/src/BootstrapBlazor/Components/Table/TableExtensionButton.razor.cs
index 6ee076410..a3499c8d7 100644
--- a/src/BootstrapBlazor/Components/Table/TableExtensionButton.razor.cs
+++ b/src/BootstrapBlazor/Components/Table/TableExtensionButton.razor.cs
@@ -31,6 +31,11 @@ public partial class TableExtensionButton
///
public void AddButton(ButtonBase button) => Buttons.Add(button);
+ ///
+ ///从工具栏中移除按钮
+ ///
+ public void RemoveButton(ButtonBase button) => Buttons.Remove(button);
+
private async Task OnClick(TableCellButton b)
{
if (b.OnClick.HasDelegate)
diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs
index 356517489..27f86e774 100644
--- a/test/UnitTest/Components/TableTest.cs
+++ b/test/UnitTest/Components/TableTest.cs
@@ -5435,6 +5435,17 @@ public class TableTest : TableTestBase
{
Buttons.AddButton(this);
}
+
+ ///
+ /// DisposeAsyncCore
+ ///
+ ///
+ ///
+ protected override ValueTask DisposeAsyncCore(bool disposing)
+ {
+ Buttons?.RemoveButton(this);
+ return base.DisposeAsyncCore(disposing);
+ }
}
private class MockToolbarButton : ButtonBase
--
Gitee