diff --git a/src/Controls/samples/Controls.Sample.UITests/Controls.Sample.UITests.csproj b/src/Controls/samples/Controls.Sample.UITests/Controls.Sample.UITests.csproj
index b0d6dfa2c35d..2c6296e42374 100644
--- a/src/Controls/samples/Controls.Sample.UITests/Controls.Sample.UITests.csproj
+++ b/src/Controls/samples/Controls.Sample.UITests/Controls.Sample.UITests.csproj
@@ -48,6 +48,7 @@
+
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..ac7237e30e21
--- /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..02fe6289946c
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue18716.xaml.cs
@@ -0,0 +1,19 @@
+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();
+ var urlWebViewSource = new UrlWebViewSource
+ {
+ Url = $"dotnetmaui.pdf"
+ };
+
+ WaitForStubControl.Source = urlWebViewSource;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample.UITests/Resources/Raw/dotnetmaui.pdf b/src/Controls/samples/Controls.Sample.UITests/Resources/Raw/dotnetmaui.pdf
new file mode 100644
index 000000000000..647c89e4e807
Binary files /dev/null and b/src/Controls/samples/Controls.Sample.UITests/Resources/Raw/dotnetmaui.pdf differ
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..715ed535ac3e
--- /dev/null
+++ b/src/Controls/tests/UITests/Tests/Issues/Issue18716.cs
@@ -0,0 +1,31 @@
+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";
+
+ /*
+ There's an issue getting the mouse interactions to work with Appium.
+ [Test]
+ [Category(UITestCategories.WebView)]
+ public async Task CanScrollWebView()
+ {
+ this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Windows, TestDevice.iOS });
+
+ await Task.Delay(1000); // Wait WebView to load.
+
+ App.WaitForElement("WaitForStubControl");
+ App.ScrollDown("WaitForStubControl", ScrollStrategy.Gesture, 0.75);
+ App.Screenshot("Scrolling has been done correctly.");
+ }*/
+
+ }
+}
diff --git a/src/Core/src/Platform/iOS/LayoutView.cs b/src/Core/src/Platform/iOS/LayoutView.cs
index 71718457c60a..9c8aa866485a 100644
--- a/src/Core/src/Platform/iOS/LayoutView.cs
+++ b/src/Core/src/Platform/iOS/LayoutView.cs
@@ -26,9 +26,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,14 +39,6 @@ public override void WillRemoveSubview(UIView uiview)
return null;
}
- if (!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.
-
- return null;
- }
-
if (result is LayoutView layoutView && !layoutView.UserInteractionEnabledOverride)
{
// If the child is a layout then we need to check the UserInteractionEnabledOverride
diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumScrollActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumScrollActions.cs
index 7285558bd2ef..0cd909636f75 100644
--- a/src/TestUtils/src/UITest.Appium/Actions/AppiumScrollActions.cs
+++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumScrollActions.cs
@@ -1,5 +1,6 @@
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Interactions;
+using OpenQA.Selenium.Appium.Mac;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Interactions;
using UITest.Core;
@@ -151,15 +152,7 @@ static void ScrollToLeft(AppiumDriver driver, AppiumElement element, ScrollStrat
int endX = (int)(position.X + (size.Width * swipePercentage));
int endY = startY;
-
- OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
- var scrollSequence = new ActionSequence(touchDevice, 0);
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
- scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
- scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
- scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
- driver.PerformActions([scrollSequence]);
+ PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
}
static void ScrollToDown(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
@@ -172,15 +165,7 @@ static void ScrollToDown(AppiumDriver driver, AppiumElement element, ScrollStrat
int endX = startX;
int endY = (int)(position.Y + (size.Height * 0.05));
-
- OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
- var scrollSequence = new ActionSequence(touchDevice, 0);
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
- scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
- scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
- scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
- driver.PerformActions([scrollSequence]);
+ PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
}
static void ScrollToRight(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
@@ -193,15 +178,7 @@ static void ScrollToRight(AppiumDriver driver, AppiumElement element, ScrollStra
int endX = (int)(position.X + (size.Width * 0.05));
int endY = startY;
-
- OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
- var scrollSequence = new ActionSequence(touchDevice, 0);
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
- scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
- scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
- scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
- driver.PerformActions([scrollSequence]);
+ PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
}
static void ScrollToUp(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
@@ -214,13 +191,34 @@ static void ScrollToUp(AppiumDriver driver, AppiumElement element, ScrollStrateg
int endX = startX;
int endY = (int)(position.Y + (size.Height * swipePercentage));
+ PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
+ }
+
+ static void PerformActions(
+ AppiumDriver driver,
+ int startX,
+ int startY,
+ int endX,
+ int endY,
+ ScrollStrategy strategy,
+ int swipeSpeed)
+ {
- OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
+ var pointerKind = PointerKind.Touch;
+ if (driver is MacDriver)
+ {
+ pointerKind = PointerKind.Mouse;
+ }
+
+ OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(pointerKind);
var scrollSequence = new ActionSequence(touchDevice, 0);
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
+ scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.FromMilliseconds(2)));
scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
- scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
- scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
+ scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(Math.Max(ScrollTouchDownTime, 2))));
+
+ var moveDuration = TimeSpan.FromMilliseconds(Math.Max(2, strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime));
+ scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, moveDuration));
+
scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
driver.PerformActions([scrollSequence]);
}