Skip to content

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Mar 21, 2025

Description of Change

When the device orientation changes, the ViewDidLayoutSubviews method is triggered. Inside this method, _carouselViewLoopManager.CenterIfNeeded(CollectionView, IsHorizontal) is called. This eventually leads to CollectionView.ReloadData(), which ensures proper sizing adjustments when the orientation changes.

However, if the carousel view is not looping, _carouselViewLoopManager.CenterIfNeeded is not invoked. To fix this, I call _carouselViewLoopManager.CenterIfNeeded inside TraitCollectionDidChange when the carousel view does not have looping enabled.

Issues Fixed

Fixes #28523

Before After
Screen.Recording.2025-03-21.at.00.57.25.mov
Screen.Recording.2025-03-21.at.01.27.41.mov

@kubaflo kubaflo requested a review from a team as a code owner March 21, 2025 00:43
@kubaflo kubaflo requested review from PureWeen and mattleibow March 21, 2025 00:43
@kubaflo kubaflo self-assigned this Mar 21, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Mar 21, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo kubaflo added platform/ios area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution and removed community ✨ Community Contribution labels Mar 21, 2025
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

bool _isRotating;

public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection)
{
Copy link
Member

Choose a reason for hiding this comment

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

let s say the initial view is horizontal, and then I rotate to vertical, don t I still need to reload the data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to reload the data. And it will reload because previousTraitCollection.VerticalSizeClass would be compact and TraitCollection.VerticalSizeClass regular

@mattleibow
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow mattleibow moved this from Todo to Approved in MAUI SDK Ongoing Mar 23, 2025
@mattleibow mattleibow added this to the .NET 9 SR6 milestone Mar 23, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current March 23, 2025 23:55
@PureWeen PureWeen removed this from the .NET 9 SR6 milestone Mar 23, 2025
@PureWeen PureWeen added this to the .NET 9 SR7 milestone Mar 23, 2025
@PureWeen PureWeen merged commit 0bfaa5c into dotnet:inflight/current Mar 23, 2025
126 of 128 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Mar 23, 2025
PureWeen pushed a commit that referenced this pull request Mar 26, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
PureWeen pushed a commit that referenced this pull request Mar 28, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
github-actions bot pushed a commit that referenced this pull request Apr 2, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
github-actions bot pushed a commit that referenced this pull request Apr 3, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
github-actions bot pushed a commit that referenced this pull request Apr 8, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
bhavanesh2001 pushed a commit to bhavanesh2001/maui that referenced this pull request Apr 11, 2025
…tnet#28545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
PureWeen pushed a commit that referenced this pull request Apr 11, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
github-actions bot pushed a commit that referenced this pull request Apr 11, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
github-actions bot pushed a commit that referenced this pull request Apr 14, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
github-actions bot pushed a commit that referenced this pull request Apr 15, 2025
…8545)

* [iOS] Changing carousel view orientation with disabled loop - fix

* Added snapshots
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution platform/ios

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[CarouselView] Different behavior on iOS and Android when Loop = False

5 participants