diff --git a/CodeBeam.MudBlazor.Extensions.UnitTests.Viewer/TestComponents/TransferList/TransferListTest.razor b/CodeBeam.MudBlazor.Extensions.UnitTests.Viewer/TestComponents/TransferList/TransferListTest.razor
new file mode 100644
index 00000000..b2deccf9
--- /dev/null
+++ b/CodeBeam.MudBlazor.Extensions.UnitTests.Viewer/TestComponents/TransferList/TransferListTest.razor
@@ -0,0 +1,68 @@
+@namespace MudExtensions.UnitTests.TestComponents
+@using MudBlazor.Extensions
+
+
+
+
+
+
+
+
+ Start Collection: @string.Join(", ", _startCollection ?? new List())
+ End Collection: @string.Join(", ", _endCollection ?? new List())
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@code{
+ MudTransferList _transferList = new();
+ ICollection _startCollection = new List() { "Sweden", "Hungary", "Turkey", "England", "Egypt" };
+ ICollection _endCollection = new List() { "Brazil", "China", "Germany", "USA", "South Africa" };
+
+ bool _vertical;
+ bool _multiSelection;
+ bool _preventTurkeyTransfer;
+ bool _orderOnTransfer;
+ bool _allowDoubleClick;
+ bool _searchboxStart;
+ bool _searchboxEnd;
+ int? _maxItems;
+ SelectAllType _selectAllType = SelectAllType.Buttons;
+ Color _color = Color.Primary;
+ Variant _buttonVariant = Variant.Text;
+ string _startTitle = "Country Group 1";
+ string _endTitle = "Country Group 2";
+
+ private bool CheckTransfer(bool startToEnd)
+ {
+ var valuesStart = _transferList.GetStartListSelectedValues();
+ var valuesEnd = _transferList.GetEndListSelectedValues();
+ if (_preventTurkeyTransfer == true && (valuesStart?.Contains("Turkey") == true || valuesEnd?.Contains("Turkey") == true))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private ICollection OrderMethod(ICollection e)
+ {
+ return e.Order().ToList();
+ }
+}
diff --git a/CodeBeam.MudBlazor.Extensions.UnitTests/Components/TransferListTests.cs b/CodeBeam.MudBlazor.Extensions.UnitTests/Components/TransferListTests.cs
new file mode 100644
index 00000000..08aaa989
--- /dev/null
+++ b/CodeBeam.MudBlazor.Extensions.UnitTests/Components/TransferListTests.cs
@@ -0,0 +1,26 @@
+using Bunit;
+using FluentAssertions;
+using MudExtensions.UnitTests.TestComponents;
+
+namespace MudExtensions.UnitTests.Components
+{
+ [TestFixture]
+ public class TransferListTests : BunitTest
+ {
+ [Test]
+ public async Task TransferListTransferAllTest()
+ {
+ var comp = Context.RenderComponent();
+ var transferList = comp.FindComponent>();
+ transferList.Instance.StartCollection.Should().Contain("Turkey");
+ transferList.Instance.StartCollection.Should().NotContain("China");
+ await comp.InvokeAsync(() => transferList.Instance.TransferAll(true));
+ transferList.Instance.StartCollection.Should().NotContain("Turkey");
+ transferList.Instance.EndCollection.Should().Contain("Turkey");
+ await comp.InvokeAsync(() => transferList.Instance.TransferAll(false));
+ transferList.Instance.StartCollection.Should().Contain("Turkey");
+ transferList.Instance.EndCollection.Should().NotContain("Turkey");
+ }
+
+ }
+}
diff --git a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs
index c75400f9..e39a532d 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs
+++ b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs
@@ -1653,7 +1653,7 @@ protected internal ValueTask ScrollToMiddleAsync(MudListItemExtended? item)
///
///
///
- protected ICollection? GetSearchedItems()
+ protected internal ICollection? GetSearchedItems()
{
if (!SearchBox || ItemCollection == null || _searchString == null)
{
diff --git a/CodeBeam.MudBlazor.Extensions/Components/TransferList/MudTransferList.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/TransferList/MudTransferList.razor.cs
index cfab1e79..a6adcdea 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/TransferList/MudTransferList.razor.cs
+++ b/CodeBeam.MudBlazor.Extensions/Components/TransferList/MudTransferList.razor.cs
@@ -340,24 +340,40 @@ protected internal async Task TransferAll(bool startToEnd = true)
}
if (startToEnd == true)
{
- foreach (var item in StartCollection)
+ var transferredValues = new List();
+ foreach (var item in _startList.GetSearchedItems() ?? [])
{
- EndCollection.Add(item);
+ if (item != null)
+ {
+ transferredValues.Add(item);
+ }
+ }
+
+ foreach (var item in transferredValues ?? [])
+ {
+ EndCollection?.Add(item);
+ StartCollection?.Remove(item);
}
- StartCollection.Clear();
- _startList.Clear();
OrderItems();
await EndCollectionChanged.InvokeAsync(EndCollection);
await StartCollectionChanged.InvokeAsync(StartCollection);
}
else if (startToEnd == false)
{
- foreach (var item in EndCollection)
+ var transferredValues = new List();
+ foreach (var item in _endList.GetSearchedItems() ?? [])
+ {
+ if (item != null)
+ {
+ transferredValues.Add(item);
+ }
+ }
+
+ foreach (var item in transferredValues ?? [])
{
- StartCollection.Add(item);
+ StartCollection?.Add(item);
+ EndCollection?.Remove(item);
}
- EndCollection.Clear();
- _endList.Clear();
OrderItems();
await StartCollectionChanged.InvokeAsync(StartCollection);
await EndCollectionChanged.InvokeAsync(EndCollection);