I read a bunch of threads here and this doesn't seem to be addressed.
I have a Gallery (AllChecklists) and for the purposes of this discussion, the other pages and forms don't even matter. All of the behaviour I'm concerned about happens right in the Gallery.
Page Properties:
OnVisible
UpdateContext({SortOrder: If(IsBlank(SortOrder), "Ascending", SortOrder)});
UpdateContext({CompFilter: If(IsBlank(CompFilter), "Yes", CompFilter)});
UpdateContext({ScrollPosition: 0})
Gallery [AllChecklists] Properties:
Items:
Sort(
Filter('IBC Checklists', Completed = If(CompFilter = "No", true, false)
),
Created,
SortOrder
)
OnSelect:
UpdateContext({positionVal: ThisItem})
Sorting Icon Properties:
OnSelect:
If(
SortOrder = "Ascending",
UpdateContext({SortOrder: "Descending"}),
UpdateContext({SortOrder: "Ascending"})
);
UpdateContext({positionVal: Blank()});
Reset(AllChecklists);
Select(AllChecklists, 1);
So it works...MOST OF THE TIME.
Here is what happens:
If I change the sort direction using the Icon when I have selected ANY record on the first 'page' in the gallery everything works perfectly. If however, I choose a record that is 'near' the end of the Gallery but not AT the end, it will decide to Reset the Gallery and Select the Last record instead of the first record.
I think the answer is changing the Select(AllChecklists, 1) function but I don't know why or how. Why does "1" arbitrarily change?