We have moved to GitHub Issues
You are viewing the read-only archive of Umbraco's issue tracker. To create new issues, please head over to GitHub Issues.
Make sure to read the blog posts announcing the move for more information.
Created by Jeavon Leopold 29 Jul 2013, 11:58:02 Updated by Stephan 01 Nov 2013, 08:08:33
A very simple tree of: Homepage -->Page1 -->Page3 -->Page2
Test code sample checking the IsFirst and IsLast methods against the collection
@{ var subPages = Model.Content.Children;
foreach (var item in subPages)
{
//var selectedItemState = item.DescendantsOrSelf().Any(x => x.Id == Model.Content.Id);
var isLastUmb = item.IsLast();
var isFirstUmb = item.IsFirst();
var isLastLinq = item.Equals(subPages.Last());
var isFirstLinq = item.Equals(subPages.First());
var alertFirst = isFirstUmb != isFirstLinq ? " style='color:red'" : String.Empty;
var alertLast = isLastUmb != isLastLinq ? " style='color:red'" : String.Empty;
<p>@item.Name<br/>
<span @Html.Raw(alertFirst)>IsFirst: @isFirstUmb : @isFirstLinq</span><br/>
<span @Html.Raw(alertLast)>IsLast: @isLastUmb : @isLastLinq</span></p>
}
}
This is fine and displays:
Page1 IsFirst: True : True IsLast: False : False
Page3 IsFirst: False : False IsLast: False : False
Page2 IsFirst: False : False IsLast: True : True
However now uncommment the DescendantsOrSelf() check and then this is what displays:
Page1 IsFirst: True : True IsLast: True : False
Page3 IsFirst: True : False IsLast: True : False
Page2 IsFirst: True : False IsLast: True : True
As you can see it's different and the IsFirst and IsLast helpers are returning incorrectly...
Maybe similar to U4-1842
I haven't looked in details at that precise bug but I can confirm that in 6.x (as of today) the management of collections is somewhat buggy and IsFirst, IsLast, etc. have issues. Have it fixed, must commit the code soon as I have a bit of time.
Excellent, this is a really strange one as you can see just executing this method changes IsFirst on the items in the existing collection. Thanks Stephan
Any update on this issue Stephan?
Fixed in 6.2.0-pubcontent branch, which should be merged soon to be part of 6.2.0. Stay tuned.
Merged into 6.2.0, 7.0.0.
Awesome Stephan!
@Stephen, is this completed? If so can you mark as fixed?
Yup
Priority: Normal
Type: Bug
State: Fixed
Assignee:
Difficulty: Normal
Category:
Backwards Compatible: True
Fix Submitted:
Affected versions: 6.1.3
Due in version: 7.0.0, 6.2.0
Sprint:
Story Points:
Cycle: