Skip to content

[iOS] CurrentItem does not work when PeekAreaInsets is set - fix #29995

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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 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

@@ -337,7 +337,7 @@ public static UICollectionViewLayout CreateCarouselLayout(
return;
}

Copy link
Preview

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

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

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 platform/ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CarouselViewHandler2] CurrentItem does not work when PeekAreaInsets is set
3 participants