Skip to content

Commit

Permalink
fix: failing gtk test
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsashah45 committed Aug 21, 2024
1 parent ca097d9 commit 4e4abde
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public async Task When_ItemClicked_SelectsCorrectIndex()
TestServices.WindowHelper.WindowContent = listViewBase;
await TestServices.WindowHelper.WaitForLoaded(listViewBase);

loggingSelectionInfo.SafeMoveCurrentToPosition(0);

// We don't use ActualWidth because of https://github.com/unoplatform/uno/issues/15982
var tapTarget = listViewBase.TransformToVisual(null).TransformPoint(new Point(112 * 0.9, listViewBase.ActualHeight / 2));
var injector = InputInjector.TryCreate() ?? throw new InvalidOperationException("Failed to init the InputInjector");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public void SafeMoveCurrentTo(object item)

public void SafeMoveCurrentToPosition(int index)
{
if (index == -1)
{
MethodLog.Add("MoveCurrentToPosition() - Skipped due to invalid index (-1)");
return;
}
if (IsUsingISelectionInfo)
{
MethodLog.Add("MoveCurrentToPosition() - Skipped due to ISelectionInfo usage");
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ internal override void OnItemClicked(int clickedIndex, VirtualKeyModifiers modif

void SingleSelectionCase()
{

//Verifying if the ItemsSource is a CollectionView and not ISelectionInfo
if (ItemsSource is ICollectionView collectionView and not ISelectionInfo)
{
//NOTE: Windows seems to call MoveCurrentTo(item); we set position instead to have expected behavior when you have duplicate items in the list.
Expand Down

0 comments on commit 4e4abde

Please sign in to comment.