Skip to content
Closed
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
@@ -0,0 +1,17 @@
<?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.Issue18716">
<Grid
RowDefinitions="*, Auto">
<WebView
x:Name="WaitForStubControl"
AutomationId="WaitForStubControl"
Source="https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_1MB_PDF.pdf">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to maybe add a local pdf that would make sure we don't hit any connection issues loading this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can maybe at least host the pdf in the maui repo since we cannot control what this pdf is/does in the future.

</WebView>
<Label
x:Name="LoadedControl"
AutomationId="LoadedControl" />
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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();
}

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";
}
}
}
30 changes: 30 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue18716.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be worth enabling for all platforms?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled on more platforms. Scrolling using gestures, so Android and iOS.


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);
App.Screenshot("Scrolling has been done correctly.");
}
}
}
13 changes: 8 additions & 5 deletions src/Core/src/Platform/iOS/LayoutView.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Linq;
using CoreGraphics;
using UIKit;

Expand All @@ -6,7 +8,7 @@ namespace Microsoft.Maui.Platform
public class LayoutView : MauiView
{
bool _userInteractionEnabled;

public override void SubviewAdded(UIView uiview)
{
InvalidateConstraintsCache();
Expand All @@ -26,9 +28,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
Expand All @@ -37,11 +41,10 @@ public override void WillRemoveSubview(UIView uiview)
return null;
}

if (!result.UserInteractionEnabled)
if (Subviews.Contains(result) && !result.UserInteractionEnabled)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to rather do result.Superview == this instead of getting the subviews array and looping through them all?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I am thinking we can't just check the result, we need to find the parent that is the child of the layout. So I am thinking:

while (result.Superview is not null && result.Superview != this)
    result = result.Superview;
if (result.Superview == this && !result.UserInteractionEnabled)

If we have a secret scroll view in our webview, we still need to find that webview and read the property the user set in XAML.

{
// 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;
}

Expand Down
5 changes: 0 additions & 5 deletions src/TestUtils/src/UITest.Appium/HelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object>()
Expand Down