Describe the bug
When you update collection by resetting property ItemsSource is binded to, focused element preserves its position and context.
Steps to reproduce the bug
Test project
1) Start project
2) Delete any item by clicking delete button on item in ItemsRepeater
3) This item is retained even though the collection does not contain it
Video of how it looks, compared to ListView:
https://www.youtube.com/embed/meEAqoaP6IQ
NuGet package version:
Microsoft.UI.Xaml 2.2.190917002
As I found out, focused elements are recycled to m_pinnedPool.
When collection changed inside and rises NotifyCollectionChanged
m_processingItemsSourceChange is set and ItemsRepeater forces pinned items to be recycled
But when I changing ItemsSource itself ItemsRepeater don't set m_processingItemsSourceChange and pinned items are keeping retained
@ranjeshj thoughts about this one?
Good find. When the ItemsSource changes, everything should be recycled.
I would like to look into this and fix it :)
This issue has popped up in the RadioButtons Commit #1623 . I'm going to reopen the issue. You can reproduce the issue by running the new RadioButtons test ControlKeyKeyboardTest, which passes on OS versions higher than RS2 despite showcasing this bug.
I think Stephen figured out the issue. It is repro'ing for NonVirtualizing layouts - so the fix needs to be taken out of the if block.
From my understanding, the fix for VirtualizingLayouts is relying on VirtualizingLayout::OnItemsChangedCore
which is only available for VirtualizingLayouts.
@ranjeshj, @StephenLPeters Do you have any idea what might help in that situation? 馃槄
From my understanding, the fix for VirtualizingLayouts is relying on
VirtualizingLayout::OnItemsChangedCore
which is only available for VirtualizingLayouts.@ranjeshj, @StephenLPeters Do you have any idea what might help in that situation?
I have a fix for this, ill push a PR tomorrow probably.
Most helpful comment
I would like to look into this and fix it :)