Skip to content
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

Merged
merged 4 commits into from
Jul 5, 2024

Conversation

BurningLights
Copy link
Contributor

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

@BurningLights BurningLights requested a review from a team as a code owner July 1, 2024 00:13
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 1, 2024
Copy link
Member

@mattleibow mattleibow left a 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

src/Controls/src/Core/Picker/Picker.cs Outdated Show resolved Hide resolved
@BurningLights
Copy link
Contributor Author

Yes, I can add some tests to this PR.

@BurningLights
Copy link
Contributor Author

I added the unit tests, and hopefully made the code that was pointed out as hard to read easier to understand.

@mattleibow
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow
Copy link
Member

Thanks for the updated code and comments. And the tests! All seems to be legit, but we shall wait for CI to confirm.

@PureWeen
Copy link
Member

PureWeen commented Jul 5, 2024

/rebase

… interacts with SelectedItem and SelectedIndex.
…ead. Added unit tests for Picker to check SelectedIndex and SelectedItem when adding/removing single and multiple items.
@PureWeen
Copy link
Member

PureWeen commented Jul 5, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen merged commit 84ae20f into dotnet:main Jul 5, 2024
47 checks passed
@BurningLights BurningLights deleted the picker-fixes branch July 7, 2024 11:21
@samhouts samhouts added fixed-in-8.0.70 fixed-in-net9.0-nightly This may be available in a nightly release! labels Aug 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community ✨ Community Contribution fixed-in-8.0.70 fixed-in-net9.0-nightly This may be available in a nightly release!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Picker regression in 8.0.60
4 participants