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

Fixed CollectionView SelectedItem binding issue on initial loading #25555

Merged
merged 32 commits into from
Nov 26, 2024

Conversation

SuthiYuvaraj
Copy link
Contributor

@SuthiYuvaraj SuthiYuvaraj commented Oct 28, 2024

Issue Details

  1. Selected Item Binding Issue: The selected item binding does not work as expected across Windows, iOS, and Mac platforms.
  2. Visual State Issue: If a selection visual state is present, it is not applied to the view.

Root Cause

  • Windows: The selected item is reset due to the ListViewBase.IsSynchronizedWithCurrentItem property setting. Additionally, the visual state is applied before the item view control is created.
  • iOS & Mac: The selected index is not applied during initial loading, specifically after updating the ItemsSource.

Fix Details

  • Windows: The existing local variable is used to prevent resetting SelectedItem while updating the native view property. Additionally, the ItemContentControl's visual state is now applied after it is created.
  • iOS & Mac: The selected index is applied within a batch update to ensure that items are generated before applying selection.

Reference:
iOS - ios - How to select some items in the UICollectionView after it first load? - Stack Overflow

Issues Fixed

Fixes #25551
Fixes #23299

Output Screenshot

Before Issue Fix After Issue Fix
Before Fix video After Fix video
Before Fix video After Fix video

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 28, 2024
@SuthiYuvaraj SuthiYuvaraj changed the title CollectionView Programmatic-Selection is not updated when binding the selectedItem Fixed CollectionView SelectedItem binding issue on initial loading Oct 28, 2024
@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Oct 29, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@SuthiYuvaraj SuthiYuvaraj marked this pull request as ready for review October 30, 2024 10:54
@SuthiYuvaraj SuthiYuvaraj requested a review from a team as a code owner October 30, 2024 10:54
@dotnet dotnet deleted a comment from azure-pipelines bot Oct 30, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 9 SR1 milestone Oct 30, 2024
@rmarinho rmarinho self-assigned this Oct 31, 2024
@jfversluis
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CollectionViewPreSelectionShouldUpdate

Failing

@SuthiYuvaraj
Copy link
Contributor Author

Hi @PureWeen , The CollectionViewPreSelectionShouldUpdate failed due to a missing snapshot on the Windows platform. We have now included the snapshot. Please review and let us know if there are any concerns.

@rmarinho
Copy link
Member

rmarinho commented Nov 7, 2024

/rebase

@PureWeen PureWeen modified the milestones: .NET 9 SR1, .NET 9 SR1.1 Nov 7, 2024
@dotnet dotnet deleted a comment from azure-pipelines bot Nov 12, 2024
@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

/rebase

@PureWeen PureWeen modified the milestones: .NET 9 SR1.1, .NET 9 SR2 Nov 25, 2024
@rmarinho rmarinho requested review from PureWeen, jsuarezruiz, Foda and rmarinho and removed request for Eilon, StephaneDelcroix and PureWeen November 26, 2024 16:00
@rmarinho rmarinho merged commit 60976d1 into dotnet:main Nov 26, 2024
106 of 108 checks passed
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
@samhouts samhouts added fixed-in-9.0.21 fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution fixed-in-9.0.21 fixed-in-net8.0-nightly This may be available in a nightly release! partner/syncfusion Issues / PR's with Syncfusion collaboration platform/iOS 🍎 platform/windows 🪟
Projects
Status: Done
9 participants