KEMBAR78
[iOS] CurrentItem does not work when PeekAreaInsets is set - fix by kubaflo · Pull Request #29995 · dotnet/maui · GitHub
Skip to content

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jun 14, 2025

…is set

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issues Fixed

Fixes #28524

Before After
Screen.Recording.2025-06-14.at.12.16.00.mov
Screen.Recording.2025-06-14.at.12.15.02.mov

@Copilot Copilot AI review requested due to automatic review settings June 14, 2025 10:21
@kubaflo kubaflo requested a review from a team as a code owner June 14, 2025 10:21
@kubaflo kubaflo self-assigned this Jun 14, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses an issue in CarouselViewHandler2 where the CurrentItem calculation malfunctions when PeekAreaInsets is set. The updated logic adjusts the content width used for computing the page index by subtracting the section margins.

  • Adjusted calculation for determining the carousel page index
  • Fixed CurrentItem positioning when PeekAreaInsets is applied

{
return;
}

Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

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

Consider adding a brief inline comment to clarify why sectionMargin is subtracted twice from the container width, which will help future maintainers understand the intention behind this calculation.

Suggested change
// Calculate the current page index based on the offset and container width.
// Subtract sectionMargin * 2 to account for the margins on both sides of the container.

Copilot uses AI. Check for mistakes.

@kubaflo kubaflo added platform/ios area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Jun 14, 2025
@kubaflo kubaflo changed the title [CarouselViewHandler2] CurrentItem does not work when PeekAreaInsets is set - fix [iOS] CurrentItem does not work when PeekAreaInsets is set - fix Jun 14, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 14, 2025
@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

Could include a related test?

@kubaflo
Copy link
Contributor Author

kubaflo commented Jun 16, 2025

Could include a related test?

Done

@PureWeen PureWeen added this to the .NET 9 SR11 milestone Aug 4, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Aug 4, 2025
@PureWeen
Copy link
Member

/rebase

@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 9 SR11, .NET 9 SR12 Sep 10, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Sep 10, 2025
App.WaitForElement("CarouselView");
App.ScrollRight("CarouselView");
App.ScrollRight("CarouselView");
App.WaitForElement("Blue Monkey");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also test rotating the device? That should impact env.Container.ContentSize.Width.

}

var page = (offset.X + sectionMargin) / env.Container.ContentSize.Width;
var page = (offset.X + sectionMargin) / (env.Container.ContentSize.Width - sectionMargin * 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could have negative page calculations causing crashes? For example, using a big value for PeekAreaInsets (like 250). Not usual scenario, but, could we protect it?

@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Sep 18, 2025
@PureWeen PureWeen changed the base branch from main to inflight/candidate September 18, 2025 20:43
@PureWeen PureWeen merged commit b16945f into dotnet:inflight/candidate Sep 18, 2025
131 checks passed
@github-project-automation github-project-automation bot moved this from Changes Requested to Done in MAUI SDK Ongoing Sep 18, 2025
github-actions bot pushed a commit that referenced this pull request Sep 18, 2025
)

* [CarouselViewHandler2] CurrentItem does not work when PeekAreaInsets is set

* Added a UITest
github-actions bot pushed a commit that referenced this pull request Sep 23, 2025
)

* [CarouselViewHandler2] CurrentItem does not work when PeekAreaInsets is set

* Added a UITest
github-actions bot pushed a commit that referenced this pull request Sep 23, 2025
)

* [CarouselViewHandler2] CurrentItem does not work when PeekAreaInsets is set

* Added a UITest
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 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 p/0 Work that we can't release without platform/ios

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[CarouselViewHandler2] CurrentItem does not work when PeekAreaInsets is set

3 participants