-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix: WebView inside SwipeView not responding to swipe gestures on Android #36231
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
Changes from all commits
9195056
d0ac8ca
335eee7
179c2d1
981cd4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 36154, "WebView inside SwipeView no longer responds to swipe gestures on Android", PlatformAffected.Android)] | ||
| public class Issue36154 : ContentPage | ||
| { | ||
| public Issue36154() | ||
| { | ||
| var directionLabel = new Label | ||
| { | ||
| AutomationId = "DirectionLabel", | ||
| Text = "Direction: — Offset: 0", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| Margin = new Thickness(4, 8), | ||
| FontSize = 13 | ||
| }; | ||
|
|
||
| var resultLabel = new Label | ||
| { | ||
| AutomationId = "ResultLabel", | ||
| Text = "Swipe result will appear here", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| Margin = new Thickness(4, 0, 4, 12), | ||
| FontSize = 13, | ||
| TextColor = Colors.Gray | ||
| }; | ||
|
|
||
| var webView = new WebView | ||
| { | ||
| AutomationId = "TheWebView", | ||
| HorizontalOptions = LayoutOptions.Fill, | ||
| VerticalOptions = LayoutOptions.Fill, | ||
| // Long scrollable page so vertical scroll can be verified | ||
| Source = new HtmlWebViewSource | ||
| { | ||
| Html = """ | ||
| <html> | ||
| <body style="font-family:sans-serif;padding:16px"> | ||
| <h3>Issue 36154 – WebView scroll test</h3> | ||
| <p>Scroll down to verify WebView vertical scrolling works inside SwipeView.</p> | ||
| <p>Then swipe left/right to reveal swipe items.</p> | ||
| <p>At the top edge, swipe down to reveal TopItems.</p> | ||
| <p>At the bottom edge, swipe up to reveal BottomItems.</p> | ||
| """ + string.Concat(Enumerable.Range(1, 40).Select(i => | ||
| $"<p>Line {i}: Lorem ipsum dolor sit amet consectetur adipiscing elit.</p>")) | ||
| + "</body></html>" | ||
| } | ||
| }; | ||
|
|
||
| var swipeView = new SwipeView | ||
| { | ||
| AutomationId = "TheSwipeView", | ||
| Threshold = 80, | ||
|
|
||
| LeftItems = new SwipeItems(new[] | ||
| { | ||
| new SwipeItem | ||
| { | ||
| AutomationId = "LeftItem", | ||
| Text = "◀ LEFT", | ||
| BackgroundColor = Colors.MediumSeaGreen, | ||
| Command = new Command(() => | ||
| { | ||
| resultLabel.Text = "LEFT item invoked"; | ||
| }) | ||
| } | ||
| }) | ||
| { Mode = SwipeMode.Execute, SwipeBehaviorOnInvoked = SwipeBehaviorOnInvoked.Close }, | ||
|
|
||
| RightItems = new SwipeItems(new[] | ||
| { | ||
| new SwipeItem | ||
| { | ||
| AutomationId = "RightItem", | ||
| Text = "RIGHT ▶", | ||
| BackgroundColor = Colors.CornflowerBlue, | ||
| Command = new Command(() => | ||
| { | ||
| resultLabel.Text = "RIGHT invoked!"; | ||
| }) | ||
| } | ||
| }) | ||
| { Mode = SwipeMode.Execute, SwipeBehaviorOnInvoked = SwipeBehaviorOnInvoked.Close }, | ||
|
|
||
| Content = webView | ||
| }; | ||
|
|
||
| swipeView.SwipeStarted += (s, e) => | ||
| { | ||
| directionLabel.Text = $"Direction: {e.SwipeDirection} Offset: 0"; | ||
| }; | ||
|
|
||
| swipeView.SwipeChanging += (s, e) => | ||
| directionLabel.Text = $"Direction: {e.SwipeDirection} Offset: {e.Offset:F0}"; | ||
|
|
||
| swipeView.SwipeEnded += (s, e) => | ||
| { | ||
| directionLabel.Text = $"Direction: {e.SwipeDirection} Open: {e.IsOpen}"; | ||
| }; | ||
|
|
||
| Content = new Grid | ||
| { | ||
| RowDefinitions = | ||
| [ | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Star }, | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| ], | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Swipe on WebView · scroll mid-page · swipe at edges", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| Margin = new Thickness(8), | ||
| FontSize = 13, | ||
| FontAttributes = FontAttributes.Bold | ||
| }.Row(0), | ||
|
Check failure on line 118 in src/Controls/tests/TestCases.HostApp/Issues/Issue36154.cs
|
||
|
|
||
| swipeView.Row(1), | ||
|
Check failure on line 120 in src/Controls/tests/TestCases.HostApp/Issues/Issue36154.cs
|
||
| directionLabel.Row(2), | ||
|
Check failure on line 121 in src/Controls/tests/TestCases.HostApp/Issues/Issue36154.cs
|
||
| resultLabel.Row(3) | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue36154 : _IssuesUITest | ||
| { | ||
| public Issue36154(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "WebView inside SwipeView no longer responds to swipe gestures on Android"; | ||
|
|
||
| // Verify that swiping left on the WebView reveals the Right swipe items | ||
| [Test] | ||
| [Category(UITestCategories.SwipeView)] | ||
| public void Issue36154SwipeViewShouldRevealItems() | ||
| { | ||
| var rect = App.WaitForElement("TheSwipeView").GetRect(); | ||
| var centerX = rect.X + rect.Width / 2; | ||
| var centerY = rect.Y + rect.Height / 2; | ||
|
|
||
| // Swipe left (finger moves left) → reveals RightItems | ||
| App.DragCoordinates(centerX, centerY, centerX - 200, centerY); | ||
|
|
||
| Assert.That(App.WaitForElement("ResultLabel").GetText(), Is.EqualTo("RIGHT invoked!")); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.