From df48fe6776e73c0289f3263d12d05b112c1ffae2 Mon Sep 17 00:00:00 2001 From: tj-devel709 Date: Fri, 19 Apr 2024 09:35:26 -0500 Subject: [PATCH 1/4] Add UITest and use IsDescendant of ContainverVC --- .../Issues/Issue21630.xaml | 80 +++++++++++++++++++ .../Issues/Issue21630.xaml.cs | 14 ++++ .../tests/UITests/Tests/Issues/Issue21630.cs | 37 +++++++++ .../Platform/iOS/KeyboardAutoManagerScroll.cs | 3 +- 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml create mode 100644 src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml.cs create mode 100644 src/Controls/tests/UITests/Tests/Issues/Issue21630.cs diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml new file mode 100644 index 000000000000..2b125f38818a --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + asdf + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml.cs b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml.cs new file mode 100644 index 000000000000..1866cb6335b8 --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml.cs @@ -0,0 +1,14 @@ +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(); + } +} diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue21630.cs b/src/Controls/tests/UITests/Tests/Issues/Issue21630.cs new file mode 100644 index 000000000000..c0a464ac12ee --- /dev/null +++ b/src/Controls/tests/UITests/Tests/Issues/Issue21630.cs @@ -0,0 +1,37 @@ +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"; + + [Test] + public void NavBarEntryDoesNotTriggerKeyboardScroll() + { + var navBarEntry = App.WaitForElement(NavBarEntry); + var navBarLocation = navBarEntry.GetRect(); + var headerEntry = App.WaitForElement(HeaderEntry); + var headerLocation = headerEntry.GetRect(); + + App.Click(NavBarEntry); + + 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); + } +} diff --git a/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs b/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs index eb91ef75040f..f4dab2bcec15 100644 --- a/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs +++ b/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs @@ -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)) { IsKeyboardAutoScrollHandling = false; return; From ac0890eed1e99ac7f51ec52169afe53cc8121806 Mon Sep 17 00:00:00 2001 From: tj-devel709 Date: Fri, 19 Apr 2024 13:49:03 -0500 Subject: [PATCH 2/4] Add button to focus entry in the navbar --- .../samples/Controls.Sample.UITests/Issues/Issue21630.xaml | 3 ++- .../Controls.Sample.UITests/Issues/Issue21630.xaml.cs | 6 ++++++ src/Controls/tests/UITests/Tests/Issues/Issue21630.cs | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml index 2b125f38818a..f86b392cd833 100644 --- a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21630.xaml @@ -6,7 +6,7 @@ - + @@ -58,6 +58,7 @@ +