Skip to content
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

[iOS] Add UITest for #21806 #21951

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue21630"
Title="Issue21630">

<NavigationPage.TitleView>
<HorizontalStackLayout Spacing="40">
<Entry BackgroundColor="Yellow" Text="Input Entry" AutomationId="NavBarEntry" x:Name="NavBarEntry"/>
</HorizontalStackLayout>
</NavigationPage.TitleView>

<CollectionView
SelectionMode="None"
BackgroundColor="white"
Margin="10.0">

<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
<x:String>asdf</x:String>
</x:Array>
</CollectionView.ItemsSource>

<CollectionView.ItemsLayout>
<LinearItemsLayout
Orientation="Vertical"
ItemSpacing="15"/>
</CollectionView.ItemsLayout>

<CollectionView.Header>
<VerticalStackLayout Spacing="20" Padding="10,20">
<Entry BackgroundColor="Yellow" Text="Input Entry" AutomationId="HeaderEntry"/>
<Button Text="Focus NavBarEntry" Clicked="FocusNavBarEntry" AutomationId="FocusButton"/>
</VerticalStackLayout>
</CollectionView.Header>

<CollectionView.Footer>
<ContentView HeightRequest="100"></ContentView>
</CollectionView.Footer>

<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Border
StrokeThickness="0.6">
<Label
Text="{Binding}"
FontSize="20"/>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>

</CollectionView>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 21630, "Entries in NavBar don't trigger keyboard scroll", PlatformAffected.iOS)]
public partial class Issue21630 : ContentPage
{
public Issue21630()
{
InitializeComponent();
}

void FocusNavBarEntry (object sender, EventArgs e)
{
NavBarEntry.Focus();
}
}
38 changes: 38 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue21630.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues;

public class Issue21630 : _IssuesUITest
{
public override string Issue => "Entries in NavBar don't trigger keyboard scroll";

public Issue21630(TestDevice device)
: base(device)
{ }

string NavBarEntry => "NavBarEntry";
string HeaderEntry => "HeaderEntry";
string FocusButton => "FocusButton";

[Test]
public void NavBarEntryDoesNotTriggerKeyboardScroll()
{
var navBarEntry = App.WaitForElement(NavBarEntry);
var navBarLocation = navBarEntry.GetRect();
var headerEntry = App.WaitForElement(HeaderEntry);
var headerLocation = headerEntry.GetRect();

App.Click(FocusButton);

var newNavBarEntry = App.WaitForElement(NavBarEntry);
var newNavBarEntryLocation = newNavBarEntry.GetRect();
Assert.AreEqual(navBarLocation, newNavBarEntryLocation);

var newHeaderEntry = App.WaitForElement(HeaderEntry);
var newHeaderLocation = newHeaderEntry.GetRect();

Assert.AreEqual(headerLocation, newHeaderLocation);
}
}
3 changes: 2 additions & 1 deletion src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ internal static async Task AdjustPositionDebounce()
internal static void AdjustPosition()
{
if (ContainerView is null
|| (View is not UITextField && View is not UITextView))
|| (View is not UITextField && View is not UITextView)
|| !View.IsDescendantOfView(ContainerView))
PureWeen marked this conversation as resolved.
Show resolved Hide resolved
{
IsKeyboardAutoScrollHandling = false;
return;
Expand Down
Loading