-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[CV2] Fix CarouselView vertical scrolling when orientation is horizontal #31395
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
[CV2] Fix CarouselView vertical scrolling when orientation is horizontal #31395
Conversation
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 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.
Pull Request Overview
This PR fixes a bug in CarouselView where content was unintentionally scrolling vertically even when the orientation was set to horizontal on iOS. The issue was caused by improper bounce behavior configuration in the underlying UICollectionView.
Key changes:
- Added proper bounce direction configuration based on CarouselView orientation
- Created UI tests to validate the fix behavior
- Ensured bounce only occurs in the intended scroll direction
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Controls/src/Core/Handlers/Items2/iOS/CarouselViewController2.cs |
Added UpdateScrollingConstraints() method to configure bounce behavior based on orientation |
src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs |
Called the new constraint update method when layout changes |
src/Controls/tests/TestCases.HostApp/Issues/Issue31361.cs |
Created UI test page that demonstrates the carousel behavior with scroll detection |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31361.cs |
Added automated test to verify vertical scrolling is prevented in horizontal CarouselView |
| carouselView.Scrolled += (s, e) => | ||
| { | ||
| if (e.VerticalDelta < 0) | ||
| { | ||
| contentLabel.Text = "The content is scrollable"; | ||
| } | ||
| }; |
Copilot
AI
Sep 1, 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.
The scroll detection logic only checks for VerticalDelta < 0 (upward scrolling), but vertical scrolling in either direction should indicate the bug is present. This should check e.VerticalDelta != 0 to detect any vertical movement.
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…tal (#31395) * Fix the vertical scrolling issue * Modified the logics * Added test case * modified the test case * Modified the test case * modified the test case * Added test case for vertical orientation * Added test cases
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!
Issue Details
The CarouselView's current item content scrolls vertically even when the orientation is set to horizontal.
Root Cause
The bounce behavior was not properly disabled in CarouselView. Specifically, the UICollectionView’s AlwaysBounceVertical and AlwaysBounceHorizontal properties were not configured according to the CarouselView's orientation.
Description of Change
Configured the UICollectionView’s AlwaysBounceVertical and AlwaysBounceHorizontal properties based on the CarouselView's orientation to prevent unintended scrolling.
Validated the behavior in the following platforms
Issues Fixed
Fixes #31361
Output ScreenShot
BeforeFix.mov
AfterFix.mov