I was able to create a workaround for the problem. Below are the details. But let me first describe another way the problem manifests:
Given the following:
- a SharePoint list ("Test") with 20 entries.
- a Gallery referencing this list. The template is large, showing only the first item of the Gallery practically. Therefore, scrolling down is necessary to see the other 19 items.
- a Toggle in the Gallery's template.
- a Label in the Gallery's template displaying Text=Toggle1.Value.
When the Toggle in the first Gallery item is set to true, its Label shows true (as expected). While scrolling down, the following two Labels show false (as expected because their Toglle has not been set to true). However, all other Labels in the remaining 17 items display true, despite the adjacent Toggle being set to false.
However, if one scrolls to the bottom after starting the app and then back up, and only then sets the Toggle in Item 1 to true, only the first Label shows true, while all others display false. In this case, the app behaves as expected.
So, my workaround looks like this: In the OnChange property of the Toggle, I create a context variable storing the ID of the item located at the bottom of the Gallery that was edited:
If(ThisItem.ID > MaxId, UpdateContext({MaxId: ThisItem.ID}), false)
This way, the app knows how far down the user has scrolled at least. In the Label's text, I write:
If(ThisItem.ID <= MaxId, Toggle1.Value, false)
This means that only the Labels in the items that the user has scrolled to will display the value of their Toggle. All other Labels show false because the user hasn't scrolled down to those yet.
Perhaps you might have a better solution in mind?
Thank you for the support.