@foreach (var item in Items)
{
@ItemTemplate(item)
diff --git a/src/Core/Components/SortableList/FluentSortableList.razor.cs b/src/Core/Components/SortableList/FluentSortableList.razor.cs
index 70b3a29911..09b4f3a59a 100644
--- a/src/Core/Components/SortableList/FluentSortableList.razor.cs
+++ b/src/Core/Components/SortableList/FluentSortableList.razor.cs
@@ -126,22 +126,22 @@ protected bool GetItemFiltered(TItem item)
}
[JSInvokable]
- public void OnUpdateJS(int oldIndex, int newIndex)
+ public void OnUpdateJS(int oldIndex, int newIndex, string fromListId, string toListId)
{
if (OnUpdate.HasDelegate)
{
- // invoke the OnUpdate event passing in the oldIndex and the newIndex
- OnUpdate.InvokeAsync(new FluentSortableListEventArgs(oldIndex, newIndex));
+ // invoke the OnUpdate event passing in the oldIndex, the newIndex, the fromId and the toId
+ OnUpdate.InvokeAsync(new FluentSortableListEventArgs(oldIndex, newIndex, fromListId, toListId));
}
}
[JSInvokable]
- public void OnRemoveJS(int oldIndex, int newIndex)
+ public void OnRemoveJS(int oldIndex, int newIndex, string fromListId, string toListId)
{
if (OnRemove.HasDelegate)
{
// remove the item from the list
- OnRemove.InvokeAsync(new FluentSortableListEventArgs(oldIndex, newIndex));
+ OnRemove.InvokeAsync(new FluentSortableListEventArgs(oldIndex, newIndex, fromListId, toListId));
}
}
diff --git a/src/Core/Components/SortableList/FluentSortableList.razor.js b/src/Core/Components/SortableList/FluentSortableList.razor.js
index 857b417112..324b5e4e0d 100644
--- a/src/Core/Components/SortableList/FluentSortableList.razor.js
+++ b/src/Core/Components/SortableList/FluentSortableList.razor.js
@@ -16,7 +16,7 @@ export function init(list, group, pull, put, sort, handle, filter, fallback, com
event.to.insertBefore(event.item, event.to.childNodes[event.oldIndex]);
// Notify .NET to update its model and re-render
- component.invokeMethodAsync('OnUpdateJS', event.oldDraggableIndex, event.newDraggableIndex);
+ component.invokeMethodAsync('OnUpdateJS', event.oldDraggableIndex, event.newDraggableIndex, event.from.id, event.to.id);
},
onRemove: (event) => {
if (event.pullMode === 'clone') {
@@ -28,7 +28,7 @@ export function init(list, group, pull, put, sort, handle, filter, fallback, com
event.from.insertBefore(event.item, event.from.childNodes[event.oldIndex]);
// Notify .NET to update its model and re-render
- component.invokeMethodAsync('OnRemoveJS', event.oldDraggableIndex, event.newDraggableIndex);
+ component.invokeMethodAsync('OnRemoveJS', event.oldDraggableIndex, event.newDraggableIndex, event.from.id, event.to.id);
}
});
}
diff --git a/src/Core/Components/SortableList/FluentSortableListEventArgs.cs b/src/Core/Components/SortableList/FluentSortableListEventArgs.cs
index 07475fbcae..483ed3e23f 100644
--- a/src/Core/Components/SortableList/FluentSortableListEventArgs.cs
+++ b/src/Core/Components/SortableList/FluentSortableListEventArgs.cs
@@ -7,10 +7,12 @@ public FluentSortableListEventArgs()
}
- public FluentSortableListEventArgs(int oldIndex, int newIndex)
+ public FluentSortableListEventArgs(int oldIndex, int newIndex, string? fromListId, string? toListId)
{
OldIndex = oldIndex;
NewIndex = newIndex;
+ FromListId = fromListId;
+ ToListId = toListId;
}
///
@@ -22,4 +24,16 @@ public FluentSortableListEventArgs(int oldIndex, int newIndex)
/// Gets the index of the item in the list after the update.
///
public int NewIndex { get; }
+
+ ///
+ /// Gets the id of the list the item was in before the update.
+ /// May be null if no Id was set for
+ ///
+ public string? FromListId { get; }
+
+ ///
+ /// Gets the id of the list the item is in after the update.
+ /// May be null if no Id was set for
+ ///
+ public string? ToListId { get; }
}
diff --git a/tests/Core/SortableList/FluentSortableListTests.FluentSortableList_IdIsAdded.verified.razor.html b/tests/Core/SortableList/FluentSortableListTests.FluentSortableList_IdIsAdded.verified.razor.html
new file mode 100644
index 0000000000..6f95a3347d
--- /dev/null
+++ b/tests/Core/SortableList/FluentSortableListTests.FluentSortableList_IdIsAdded.verified.razor.html
@@ -0,0 +1,33 @@
+
+
diff --git a/tests/Core/SortableList/FluentSortableListTests.razor b/tests/Core/SortableList/FluentSortableListTests.razor
index 17686c32ea..14c623a166 100644
--- a/tests/Core/SortableList/FluentSortableListTests.razor
+++ b/tests/Core/SortableList/FluentSortableListTests.razor
@@ -1,5 +1,6 @@
@using Xunit;
@inherits TestContext
+
@code
{
public class Item
@@ -23,17 +24,81 @@
public void FluentSortableList_Default()
{
// Arrange && Act
-
+
var cut = Render(@
-
- @context.Name
-
- );
+
+ @context.Name
+
+ );
// Assert
cut.Verify();
}
+ [Fact]
+ public void FluentSortableList_IdIsAdded()
+ {
+ // Arrange && Act
+
+ var cut = Render(@
+
+ @context.Name
+
+ );
+ // Assert
+ cut.Verify();
+ }
+
+ [Fact]
+ public void FluentSortableList_OnUpdate()
+ {
+ // Arrange
+ FluentSortableListEventArgs? args = null;
+ var callback = new EventCallbackFactory().Create
+ (this, (e => args = e));
+ var sortableList = new FluentSortableList- ()
+ {
+ Items = items,
+ OnUpdate = callback
+ };
+
+ // Act
+ sortableList.OnUpdateJS(0, 1, "fromList", "toList");
+
+ // Verify
+ Assert.Equal(new FluentSortableListEventArgs(0, 1, "fromList", "toList"), args,
+ FluentSortableListEventArgsComparer);
+ }
+
+ private static bool FluentSortableListEventArgsComparer(FluentSortableListEventArgs? first, FluentSortableListEventArgs? second)
+ {
+ if (first is null || second is null)
+ {
+ return false;
+ }
+
+ if (first.FromListId is null || !first.FromListId.Equals(second.FromListId))
+ {
+ return false;
+ }
+
+ if (first.ToListId is null || !first.ToListId.Equals(second.ToListId))
+ {
+ return false;
+ }
+
+ if (first.OldIndex != second.OldIndex)
+ {
+ return false;
+ }
+
+ if (first.NewIndex != second.NewIndex)
+ {
+ return false;
+ }
+
+ return true;
+ }
}