From 00724aa4e3e42b5f217337f2f3621650a9157603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Tue, 2 Apr 2024 10:09:44 +0200 Subject: [PATCH 1/9] Added repro sample --- .../Controls.Sample.UITests/Issues/Issue18716.xaml | 12 ++++++++++++ .../Issues/Issue18716.xaml.cs | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml create mode 100644 src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml new file mode 100644 index 000000000000..ad1a8d9fcf4c --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs new file mode 100644 index 000000000000..15fcb107d002 --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs @@ -0,0 +1,13 @@ +using Microsoft.Maui.Controls; + +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 18716, "Touch events are not working on WebView when a PDF is displayed", PlatformAffected.iOS)] + public partial class Issue18716 : ContentPage + { + public Issue18716() + { + InitializeComponent(); + } + } +} \ No newline at end of file From 7d0d25259c3108050d9fa1161cb28266acdcc6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Tue, 2 Apr 2024 10:09:54 +0200 Subject: [PATCH 2/9] Fix the issue --- src/Core/src/Platform/iOS/LayoutView.cs | 26 ++++++++++++++++--- .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 1 + .../net-maccatalyst/PublicAPI.Unshipped.txt | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Core/src/Platform/iOS/LayoutView.cs b/src/Core/src/Platform/iOS/LayoutView.cs index 71718457c60a..6dc40bde51bb 100644 --- a/src/Core/src/Platform/iOS/LayoutView.cs +++ b/src/Core/src/Platform/iOS/LayoutView.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using CoreGraphics; using UIKit; @@ -7,10 +8,25 @@ public class LayoutView : MauiView { bool _userInteractionEnabled; + public LayoutView() + { + Descendants = new List(); + } + + internal List? Descendants { get; set; } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + Descendants = null; + } + public override void SubviewAdded(UIView uiview) { InvalidateConstraintsCache(); base.SubviewAdded(uiview); + Descendants?.Add(uiview); Superview?.SetNeedsLayout(); } @@ -18,6 +34,7 @@ public override void WillRemoveSubview(UIView uiview) { InvalidateConstraintsCache(); base.WillRemoveSubview(uiview); + Descendants?.Remove(uiview); Superview?.SetNeedsLayout(); } @@ -26,9 +43,11 @@ public override void WillRemoveSubview(UIView uiview) var result = base.HitTest(point, uievent); if (result is null) + { return null; + } - if (!_userInteractionEnabled && this.Equals(result)) + if (!_userInteractionEnabled && Equals(result)) { // If user interaction is disabled (IOW, if the corresponding Layout is InputTransparent), // then we exclude the LayoutView itself from hit testing. But it's children are valid @@ -37,11 +56,10 @@ public override void WillRemoveSubview(UIView uiview) return null; } - if (!result.UserInteractionEnabled) + if (Descendants is not null && Descendants.Contains(result) && !result.UserInteractionEnabled) { // If the child also has user interaction disabled (IOW the child is InputTransparent), - // then we also want to exclude it from the hit testing. - + // then we also want to exclude it from the hit testing. } return null; } diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 7e2017867d3f..94e2b38cf609 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -59,6 +59,7 @@ override Microsoft.Maui.Handlers.SwitchHandler.NeedsContainer.get -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.Platform.ContentView.WillRemoveSubview(UIKit.UIView! uiview) -> void +override Microsoft.Maui.Platform.LayoutView.Dispose(bool disposing) -> void override Microsoft.Maui.Platform.MauiActivityIndicator.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiBoxView.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiCheckBox.MovedToWindow() -> void diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 4baaf01d90b2..8e20e7508c76 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -62,6 +62,7 @@ override Microsoft.Maui.Handlers.SwitchHandler.NeedsContainer.get -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.Platform.ContentView.WillRemoveSubview(UIKit.UIView! uiview) -> void +override Microsoft.Maui.Platform.LayoutView.Dispose(bool disposing) -> void override Microsoft.Maui.Platform.MauiActivityIndicator.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiBoxView.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiCheckBox.MovedToWindow() -> void From cebaa376b3528325e4dcea4355548e75f1896725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Tue, 2 Apr 2024 10:10:04 +0200 Subject: [PATCH 3/9] Added UI Test --- .../tests/UITests/Tests/Issues/Issue18716.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Controls/tests/UITests/Tests/Issues/Issue18716.cs diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs new file mode 100644 index 000000000000..0fb471b35042 --- /dev/null +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs @@ -0,0 +1,26 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.AppiumTests.Issues +{ + public class Issue18716 : _IssuesUITest + { + public Issue18716(TestDevice device) + : base(device) + { } + + public override string Issue => "Touch events are not working on WebView when a PDF is displayed"; + + [Test] + [Category(UITestCategories.WebView)] + public void CanScrollWebView() + { + this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows }); + + App.WaitForElement("WaitForStubControl"); + App.ScrollDown("WaitForStubControl", ScrollStrategy.Gesture); + App.Screenshot("Scrolling has been done correctly."); + } + } +} From f1fab4b6cc3ba9b1aeee203ba7c7fb2b686ab55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Wed, 10 Apr 2024 13:09:05 +0200 Subject: [PATCH 4/9] Updated test --- src/Controls/tests/UITests/Tests/Issues/Issue18716.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs index 0fb471b35042..f3d8d1e22b61 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs @@ -14,9 +14,11 @@ public Issue18716(TestDevice device) [Test] [Category(UITestCategories.WebView)] - public void CanScrollWebView() + public async Task CanScrollWebView() { - this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows }); + this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Mac, TestDevice.Windows }); + + await Task.Delay(1000); // Wait WebView to load. App.WaitForElement("WaitForStubControl"); App.ScrollDown("WaitForStubControl", ScrollStrategy.Gesture); From 8058fc379e927fddf87f2dfce6f6fd3937ee7cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Tue, 16 Apr 2024 12:24:19 +0200 Subject: [PATCH 5/9] Removed Descendants usage --- src/Core/src/Platform/iOS/LayoutView.cs | 21 +++---------------- .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 1 - .../net-maccatalyst/PublicAPI.Unshipped.txt | 1 - 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/Core/src/Platform/iOS/LayoutView.cs b/src/Core/src/Platform/iOS/LayoutView.cs index 6dc40bde51bb..745b0494c4d2 100644 --- a/src/Core/src/Platform/iOS/LayoutView.cs +++ b/src/Core/src/Platform/iOS/LayoutView.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Linq; using CoreGraphics; using UIKit; @@ -7,26 +8,11 @@ namespace Microsoft.Maui.Platform public class LayoutView : MauiView { bool _userInteractionEnabled; - - public LayoutView() - { - Descendants = new List(); - } - internal List? Descendants { get; set; } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - Descendants = null; - } - public override void SubviewAdded(UIView uiview) { InvalidateConstraintsCache(); base.SubviewAdded(uiview); - Descendants?.Add(uiview); Superview?.SetNeedsLayout(); } @@ -34,7 +20,6 @@ public override void WillRemoveSubview(UIView uiview) { InvalidateConstraintsCache(); base.WillRemoveSubview(uiview); - Descendants?.Remove(uiview); Superview?.SetNeedsLayout(); } @@ -56,7 +41,7 @@ public override void WillRemoveSubview(UIView uiview) return null; } - if (Descendants is not null && Descendants.Contains(result) && !result.UserInteractionEnabled) + if (Subviews.Contains(result) && !result.UserInteractionEnabled) { // If the child also has user interaction disabled (IOW the child is InputTransparent), // then we also want to exclude it from the hit testing. } diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 94e2b38cf609..7e2017867d3f 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -59,7 +59,6 @@ override Microsoft.Maui.Handlers.SwitchHandler.NeedsContainer.get -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.Platform.ContentView.WillRemoveSubview(UIKit.UIView! uiview) -> void -override Microsoft.Maui.Platform.LayoutView.Dispose(bool disposing) -> void override Microsoft.Maui.Platform.MauiActivityIndicator.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiBoxView.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiCheckBox.MovedToWindow() -> void diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 8e20e7508c76..4baaf01d90b2 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -62,7 +62,6 @@ override Microsoft.Maui.Handlers.SwitchHandler.NeedsContainer.get -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.Platform.ContentView.WillRemoveSubview(UIKit.UIView! uiview) -> void -override Microsoft.Maui.Platform.LayoutView.Dispose(bool disposing) -> void override Microsoft.Maui.Platform.MauiActivityIndicator.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiBoxView.MovedToWindow() -> void override Microsoft.Maui.Platform.MauiCheckBox.MovedToWindow() -> void From 91a0b14beaca588df988571150a9bd561e7d7bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Tue, 16 Apr 2024 12:32:20 +0200 Subject: [PATCH 6/9] Updated test --- .../samples/Controls.Sample.UITests/Issues/Issue18716.xaml | 1 + src/Controls/tests/UITests/Tests/Issues/Issue18716.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml index ad1a8d9fcf4c..e1b24160583a 100644 --- a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml @@ -6,6 +6,7 @@ diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs index f3d8d1e22b61..4ab3602ec45c 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs @@ -16,12 +16,12 @@ public Issue18716(TestDevice device) [Category(UITestCategories.WebView)] public async Task CanScrollWebView() { - this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Mac, TestDevice.Windows }); + this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows }); await Task.Delay(1000); // Wait WebView to load. App.WaitForElement("WaitForStubControl"); - App.ScrollDown("WaitForStubControl", ScrollStrategy.Gesture); + App.ScrollDown("WaitForStubControl", ScrollStrategy.Gesture, 0.75); App.Screenshot("Scrolling has been done correctly."); } } From 39c66a53f29406bf798c352814eaba49890fb932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Thu, 25 Apr 2024 17:00:09 +0200 Subject: [PATCH 7/9] More fixes --- src/TestUtils/src/UITest.Appium/HelperExtensions.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs index 4acac365e99b..e99caac17f61 100644 --- a/src/TestUtils/src/UITest.Appium/HelperExtensions.cs +++ b/src/TestUtils/src/UITest.Appium/HelperExtensions.cs @@ -34,11 +34,6 @@ public static void Click(this IApp app, string element) app.FindElement(element).Click(); } - public static void Tap(this IApp app, string element) - { - app.FindElement(element).Click(); - } - public static string? GetText(this IUIElement element) { var response = element.Command.Execute("getText", new Dictionary() From 6f4ec3a48d32f6925b618f4088620afb09bcc534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Thu, 25 Apr 2024 17:17:00 +0200 Subject: [PATCH 8/9] Updated sample --- .../Issues/Issue18716.xaml | 6 +++++- .../Issues/Issue18716.xaml.cs | 17 +++++++++++++++++ .../tests/UITests/Tests/Issues/Issue18716.cs | 8 +++++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml index e1b24160583a..012fa697ca16 100644 --- a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml @@ -3,11 +3,15 @@ xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Maui.Controls.Sample.Issues.Issue18716"> - + + \ No newline at end of file diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs index 15fcb107d002..4e7ff6bd6e07 100644 --- a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs @@ -9,5 +9,22 @@ public Issue18716() { InitializeComponent(); } + + protected override void OnAppearing() + { + base.OnAppearing(); + WaitForStubControl.Navigating += OnWebViewNavigating; + } + + protected override void OnDisappearing() + { + base.OnDisappearing(); + WaitForStubControl.Navigating -= OnWebViewNavigating; + } + + void OnWebViewNavigating(object sender, WebNavigatingEventArgs e) + { + LoadedControl.Text = "Ready"; + } } } \ No newline at end of file diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs index 4ab3602ec45c..814cbdb720f9 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs @@ -14,11 +14,13 @@ public Issue18716(TestDevice device) [Test] [Category(UITestCategories.WebView)] - public async Task CanScrollWebView() + public void CanScrollWebView() { - this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows }); + this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Mac, TestDevice.Windows }); - await Task.Delay(1000); // Wait WebView to load. + App.WaitForElement("LoadedControl", timeout: TimeSpan.FromSeconds(1)); + var result = App.FindElement("LoadedControl").GetText(); + Assert.AreEqual("Ready", result); App.WaitForElement("WaitForStubControl"); App.ScrollDown("WaitForStubControl", ScrollStrategy.Gesture, 0.75); From 412424fdf4fea49a96febdbf13358023cbca053a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Fri, 26 Apr 2024 06:41:58 +0200 Subject: [PATCH 9/9] More changes --- src/Controls/tests/UITests/Tests/Issues/Issue18716.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs index 814cbdb720f9..8c2cd4cf7588 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs @@ -16,7 +16,7 @@ public Issue18716(TestDevice device) [Category(UITestCategories.WebView)] public void CanScrollWebView() { - this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Mac, TestDevice.Windows }); + this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows }); App.WaitForElement("LoadedControl", timeout: TimeSpan.FromSeconds(1)); var result = App.FindElement("LoadedControl").GetText();