-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing regression in Picker behavior in 8.0.60 #23369
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR.
Are you able to add some tests to ensure the selection is correct? This is all cross-platform code, so it should be fine to do in the normal unit tests project for controls: https://github.com/dotnet/maui/blob/main/src/Controls/tests/Core.UnitTests/PickerTests.cs
Yes, I can add some tests to this PR. |
I added the unit tests, and hopefully made the code that was pointed out as hard to read easier to understand. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Thanks for the updated code and comments. And the tests! All seems to be legit, but we shall wait for CI to confirm. |
/rebase |
…and incrementing SelectedIndex.
… interacts with SelectedItem and SelectedIndex.
…ead. Added unit tests for Picker to check SelectedIndex and SelectedItem when adding/removing single and multiple items.
02acfab
to
5ad8da5
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Description of Change
Correcting the logic of when to update the SelectedItem when a new item is inserted into an INotifyCollectionChanged ItemsSource. The previous code did not account for index being incremented as the new items are inserted into the Items collection, which resulted in failing to reliably update the SelectedItem to account for the inserted items. Also correcting the logic for removing items when an INotifyCollectionChanged ItemsSource has items removed. Based on the documentation, I believe the OldStartingIndex refers to the index of the first removed item, not the end of the removed range like the current behavior has.
Issues Fixed
Fixes #23367