Skip to content

Fixing regression in Picker behavior in 8.0.60#23369

Merged
PureWeen merged 4 commits into
dotnet:mainfrom
BurningLights:picker-fixes
Jul 5, 2024
Merged

Fixing regression in Picker behavior in 8.0.60#23369
PureWeen merged 4 commits into
dotnet:mainfrom
BurningLights:picker-fixes

Conversation

@BurningLights

Copy link
Copy Markdown
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
@BurningLights BurningLights requested review from Eilon and rmarinho July 1, 2024 00:13
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Jul 1, 2024

@mattleibow mattleibow left a comment

Copy link
Copy Markdown
Member

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

Comment thread src/Controls/src/Core/Picker/Picker.cs Outdated
@BurningLights

Copy link
Copy Markdown
Contributor Author

Yes, I can add some tests to this PR.

@BurningLights

Copy link
Copy Markdown
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
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow

Copy link
Copy Markdown
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

PureWeen commented Jul 5, 2024

Copy link
Copy Markdown
Member

/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

PureWeen commented Jul 5, 2024

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen merged commit 84ae20f into dotnet:main Jul 5, 2024
@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