-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[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
Conversation
There was a problem hiding this 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; | ||
| } | ||
|
|
Copilot
AI
Jun 14, 2025
There was a problem hiding this comment.
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.
| // 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.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this 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?
Done |
|
/rebase |
6f1a09c to
cbac323
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| App.WaitForElement("CarouselView"); | ||
| App.ScrollRight("CarouselView"); | ||
| App.ScrollRight("CarouselView"); | ||
| App.WaitForElement("Blue Monkey"); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
…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
Screen.Recording.2025-06-14.at.12.16.00.mov
Screen.Recording.2025-06-14.at.12.15.02.mov