umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.46k stars 2.68k forks source link

Moving item to bin doesn't update its siblings sort order #17273

Open elit0451 opened 1 week ago

elit0451 commented 1 week ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.5.1, 14.3.0, 15 RC

Bug summary

When new document nodes are created, they are always added as the last child. But in the case when you delete an item with sortOrder 0, and add a new one, it will be added as the first item. It seems like this is caused by not recalculating the sortOrder of the siblings when the first item is deleted. This means that the new node comes with sortOrder = 0, which results in taking the position as the first item.

Specifics

No response

Steps to reproduce


You can also use the content service and verify that the sortOrder property of each child doesn't reflect the correct value:

var parentId = Home.Id;
IEnumerable<IContent> children = ContentService.GetPagedChildren(parentId, 0, int.MaxValue, out _);

Expected result / actual result

Extected:

Actual

elit0451 commented 1 week ago

The same issue occurs when Moving the first item and adding a new one

manutdkid77 commented 4 days ago

Can I pick this one up ? I have been able to figure out why this is happening:

Initially we are removing the first item, which has a sortOrder of 0, and then adding a new item, here it looks like the SortOrderExists method returns false because it cant find any item with sortOrder as 0