-
Notifications
You must be signed in to change notification settings - Fork 31
Description
When using a custom component in SortableItemTemplate, the sorted output can be corrupted. Actually, it seems that sorting is right, but the display of the components doesn't happen in the correct order, and the visual result is wrong.
I created a testing repository that illustrates the issue, with a simple component that displays a text, or another one that shows an image. Both have the same issue. See here.
The following code works fine:
<SortableList Class="d-flex flex-wrap gap-2" Id="text1" Items="Texts" OnUpdate="SortList" Context="text">
<SortableItemTemplate>
<div class="card" style="width:5rem;height:5rem">
<div class="card-body">
@text
</div>
</div>
</SortableItemTemplate>
</SortableList>
But that one has the issue:
<SortableList Class="d-flex flex-wrap gap-2" Id="text1" Items="Texts" OnUpdate="SortList" Context="text">
<SortableItemTemplate>
<TextComponent Text="@text" />
</SortableItemTemplate>
</SortableList>
where TextComponent has the code from the previous section:
<div class="card" style="width:5rem;height:5rem">
<div class="card-body">
@Text
</div>
</div>
@code {
[Parameter]
public string? Text { get; set; }
}
Here is a capture showing the issue. The three blocks show the same list and the should always be synchronized, but the last one is wrong. I just moved 6 before 5. The issue only seems to happen if you start by moving an item to the left.
My feeling is that there is a synchronization issue, but I can't figure out where it comes from.
