-
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9195056
Fix : WebView inside SwipeView no longer responds to swipe gestures
SubhikshaSf4851 d0ac8ca
test sample changes
SubhikshaSf4851 335eee7
review concerns addressed
SubhikshaSf4851 179c2d1
Addressed review concern
SubhikshaSf4851 981cd4b
Merge remote-tracking branch 'origin/inflight/current' into pr36231-F…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
src/Controls/tests/TestCases.HostApp/Issues/Issue36154.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
|
|
||
| swipeView.Row(1), | ||
| directionLabel.Row(2), | ||
| resultLabel.Row(3) | ||
| } | ||
| }; | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue36154.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!")); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.