Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ ItemsView is GroupableItemsView groupableItemsView &&
return;
}

double offset = AlignToStart;
double offset = double.NaN;
switch (args.ScrollToPosition)
{
Comment on lines +1714 to 1716
case ScrollToPosition.Start:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue38057.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 38057, "CollectionView MakeVisible scrolls the target item to the top", PlatformAffected.UWP)]
public class Issue38057 : ContentPage
{
const string TargetMonkey = "Proboscis Monkey";

readonly CollectionView _collectionView;

public Issue38057()
{
string[] monkeyNames =
[
"Baboon",
"Blue Monkey",
"Capuchin Monkey",
"Colobus Monkey",
"Common Marmoset",
"De Brazza's Monkey",
"Dusky Leaf Monkey",
"Golden Lion Tamarin",
"Green Monkey",
"Howler Monkey",
"Japanese Macaque",
"Mandrill",
"Mona Monkey",
"Patas Monkey",
"Pied Tamarin",
"Pygmy Marmoset",
"Red-shanked Douc",
"Rhesus Macaque",
"Saki Monkey",
"Siamang",
"Squirrel Monkey",
"Tibetan Macaque",
"Vervet Monkey",
"White-faced Capuchin",
TargetMonkey,
"Black Snub-nosed Monkey",
"Cotton-top Tamarin",
"Gelada",
"Golden Snub-nosed Monkey",
"Spider Monkey"
];

_collectionView = new CollectionView
{
AutomationId = "MonkeyCollectionView",
ItemsSource = monkeyNames,
ItemTemplate = new DataTemplate(() =>
{
var label = new Label
{
HeightRequest = 48,
Padding = new Thickness(12),
VerticalTextAlignment = TextAlignment.Center
};

label.SetBinding(Label.TextProperty, ".");
label.SetBinding(Label.AutomationIdProperty, ".");
return label;
})
};

var scrollButton = new Button
{
AutomationId = "ScrollToProboscisMonkeyButton",
Text = "Scroll to Proboscis Monkey",
Command = new Command(() => _collectionView.ScrollTo(TargetMonkey, position: ScrollToPosition.MakeVisible, animate: false))
};

var layout = new Grid
{
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Star }
}
};

layout.Add(scrollButton);
layout.Add(_collectionView, 0, 1);
Content = layout;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue38057 : _IssuesUITest
{
public Issue38057(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "CollectionView MakeVisible scrolls the target item to the top";

[Test]
[Category(UITestCategories.CollectionView)]
public void Issue38057_MakeVisiblePositionsTargetAtBottomOfViewport()
{
App.WaitForElement("ScrollToProboscisMonkeyButton");
App.Tap("ScrollToProboscisMonkeyButton");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading