Fixing regression in Picker behavior in 8.0.60#23369
Merged
Merged
Conversation
mattleibow
requested changes
Jul 1, 2024
mattleibow
left a comment
Member
There was a problem hiding this comment.
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
Contributor
Author
|
Yes, I can add some tests to this PR. |
Contributor
Author
|
I added the unit tests, and hopefully made the code that was pointed out as hard to read easier to understand. |
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
mattleibow
approved these changes
Jul 4, 2024
Member
|
Thanks for the updated code and comments. And the tests! All seems to be legit, but we shall wait for CI to confirm. |
Member
|
/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
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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