-
Notifications
You must be signed in to change notification settings - Fork 2k
[Android] CarouselView: Fix position jump when tapping non-Start aligned Entry #34532
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
Merged
kubaflo
merged 11 commits into
dotnet:inflight/current
from
praveenkumarkarunanithi:fix-13323
Jun 22, 2026
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
029289a
fix and test updated
praveenkumarkarunanithi 7a17c49
Update PublicAPI.Unshipped.txt
praveenkumarkarunanithi 712f20c
updated test with loop scenario
praveenkumarkarunanithi c46295e
Merge branch 'dotnet:main' into fix-13323
praveenkumarkarunanithi e02b866
resolving AI agent concerns.
praveenkumarkarunanithi 65e67be
Add Issue13323 test and fix
praveenkumarkarunanithi a920f64
Update PublicAPI.Unshipped.txt
praveenkumarkarunanithi 83dc6f9
test update
praveenkumarkarunanithi 6bde759
test code update
praveenkumarkarunanithi d62f2f3
AI summary concern updates
praveenkumarkarunanithi 116f4a7
Merge branch 'inflight/current' into fix-13323
kubaflo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| #nullable enable | ||
| #nullable enable | ||
| override Microsoft.Maui.Controls.Shapes.Shape.OnPropertyChanged(string? propertyName = null) -> void | ||
| ~override Microsoft.Maui.Controls.Handlers.Items.MauiCarouselRecyclerView.RequestChildFocus(Android.Views.View! child, Android.Views.View! focused) -> void | ||
| ~override Microsoft.Maui.Controls.Handlers.Items.MauiCarouselRecyclerView.RequestChildRectangleOnScreen(Android.Views.View! child, Android.Graphics.Rect! rect, bool immediate) -> bool | ||
| ~override Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView<TItemsView, TAdapter, TItemsViewSource>.OnInterceptTouchEvent(Android.Views.MotionEvent e) -> bool | ||
| ~override Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView<TItemsView, TAdapter, TItemsViewSource>.OnTouchEvent(Android.Views.MotionEvent e) -> bool | ||
100 changes: 100 additions & 0 deletions
100
src/Controls/tests/TestCases.HostApp/Issues/Issue13323.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 13323, | ||
| "CarouselView on Android does not work if HorizontalTextAlignment in Entry is not Start", | ||
| PlatformAffected.Android)] | ||
| public class Issue13323 : ContentPage | ||
| { | ||
| public Issue13323() | ||
| { | ||
| var items = new[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; | ||
|
|
||
| var positionLabel = new Label | ||
| { | ||
| AutomationId = "PositionLabel", | ||
| Text = "Position:0", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| }; | ||
|
|
||
| var carousel = new CarouselView | ||
| { | ||
| AutomationId = "CarouselView13323", | ||
| ItemsSource = items, | ||
| Loop = false, | ||
| HeightRequest = 250, | ||
| ItemTemplate = new DataTemplate(() => | ||
| { | ||
| var entry = new Entry | ||
| { | ||
| AutomationId = "CenterEntry", | ||
| Placeholder = "Tap me", | ||
| HorizontalTextAlignment = TextAlignment.Center, | ||
| HorizontalOptions = LayoutOptions.FillAndExpand, | ||
| }; | ||
|
praveenkumarkarunanithi marked this conversation as resolved.
|
||
|
|
||
| return new Border | ||
| { | ||
| HeightRequest = 200, | ||
| Content = new VerticalStackLayout | ||
| { | ||
| VerticalOptions = LayoutOptions.Center, | ||
| Children = { entry } | ||
| } | ||
| }; | ||
| }) | ||
| }; | ||
|
|
||
| carousel.PositionChanged += (s, e) => | ||
| { | ||
| positionLabel.Text = $"Position:{carousel.Position}"; | ||
| }; | ||
|
|
||
| var loopPositionLabel = new Label | ||
| { | ||
| AutomationId = "LoopPositionLabel", | ||
| Text = "LoopPosition:0", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| }; | ||
|
|
||
| var loopCarousel = new CarouselView | ||
| { | ||
| AutomationId = "LoopCarouselView13323", | ||
| ItemsSource = items, | ||
| Loop = true, | ||
| HeightRequest = 250, | ||
| ItemTemplate = new DataTemplate(() => | ||
| { | ||
| var entry = new Entry | ||
| { | ||
| AutomationId = "LoopCenterEntry", | ||
| Placeholder = "Tap me", | ||
| HorizontalTextAlignment = TextAlignment.Center, | ||
| HorizontalOptions = LayoutOptions.FillAndExpand, | ||
| }; | ||
|
praveenkumarkarunanithi marked this conversation as resolved.
|
||
|
|
||
| return new Border | ||
| { | ||
| HeightRequest = 200, | ||
| Content = new VerticalStackLayout | ||
| { | ||
| VerticalOptions = LayoutOptions.Center, | ||
| Children = { entry } | ||
| } | ||
| }; | ||
| }) | ||
| }; | ||
|
|
||
| loopCarousel.PositionChanged += (s, e) => | ||
| { | ||
| loopPositionLabel.Text = $"LoopPosition:{loopCarousel.Position}"; | ||
| }; | ||
|
|
||
| Content = new ScrollView | ||
| { | ||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = { positionLabel, carousel, loopPositionLabel, loopCarousel } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
56 changes: 56 additions & 0 deletions
56
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue13323.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| using Microsoft.Maui.TestCases.Tests; | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.AppUITests.Issues; | ||
|
|
||
| public class Issue13323 : _IssuesUITest | ||
|
praveenkumarkarunanithi marked this conversation as resolved.
|
||
| { | ||
| public Issue13323(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "CarouselView on Android does not work if HorizontalTextAlignment in Entry is not Start"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CarouselView)] | ||
| public void CarouselView_EntryTap_DoesNotChangePosition() | ||
| { | ||
| App.WaitForElement("CarouselView13323"); | ||
|
|
||
| App.SwipeRightToLeft("CarouselView13323"); | ||
| App.SwipeRightToLeft("CarouselView13323"); | ||
|
|
||
| App.WaitForElement("Position:2"); | ||
|
|
||
| App.Tap("CenterEntry"); | ||
|
|
||
| // Position must remain at 2 after tapping Center-aligned Entry | ||
| App.WaitForElement("Position:2"); | ||
|
|
||
| var positionAfter = App.FindElement("PositionLabel").GetText(); | ||
|
praveenkumarkarunanithi marked this conversation as resolved.
praveenkumarkarunanithi marked this conversation as resolved.
|
||
| Assert.That(positionAfter, Is.EqualTo("Position:2"), $"CarouselView jumped after tapping Center-aligned Entry: {positionAfter}"); | ||
|
|
||
| App.DismissKeyboard(); | ||
| App.WaitForKeyboardToHide(); | ||
| } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CarouselView)] | ||
| public void CarouselView_Loop_EntryTap_DoesNotChangePosition() | ||
| { | ||
| App.WaitForElement("LoopCarouselView13323"); | ||
|
|
||
| App.SwipeRightToLeft("LoopCarouselView13323"); | ||
| App.SwipeRightToLeft("LoopCarouselView13323"); | ||
|
|
||
| App.WaitForElement("LoopPosition:2"); | ||
|
|
||
| App.Tap("LoopCenterEntry"); | ||
|
|
||
| // Position must remain at 2 after tapping Center-aligned Entry with Loop=true | ||
| App.WaitForElement("LoopPosition:2"); | ||
|
|
||
| var positionAfter = App.FindElement("LoopPositionLabel").GetText(); | ||
| Assert.That(positionAfter, Is.EqualTo("LoopPosition:2"), $"CarouselView (Loop=true) jumped after tapping Center-aligned Entry: {positionAfter}"); | ||
|
praveenkumarkarunanithi marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.