-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Fix for RefreshView triggering pull-to-refresh when scrolling inside a WebView with internal scrollable content #34614
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 all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
00093be
Bump Magick.NET-Q8-AnyCPU from 14.10.4 to 14.12.0 (#35315)
dependabot[bot] af01b74
Bump OpenTelemetry packages in Aspire ServiceDefaults template (#35333)
jfversluis d886e09
[main] Update dependencies from dotnet/xharness (#35292)
dotnet-maestro[bot] b71adea
History-trained agentic files + expert reviewer (#35198)
kubaflo f8cb875
[Testing] The Windows WebView category is removed from CI because Web…
TamilarasanSF4853 e752fea
fix-33510: Made code changes to prevent RefreshView from intercepting…
BagavathiPerumal ae07f1e
fix-33510-Changes updated.
BagavathiPerumal 3c51cf5
fix-33510-Simplied Testcase and test script. Additionally, updated th…
BagavathiPerumal 62ecbf5
fix-33510-Testcase updated.
BagavathiPerumal 3ed45d7
fix-33510-Code changes updated.
BagavathiPerumal 7462491
fix-33510-Updated the code changes, addressed the issue in MauiHybrid…
BagavathiPerumal 3c98c02
fix-33510-Optimized code implementation
BagavathiPerumal b4a8781
Merge branch 'inflight/current' into fix-33510
kubaflo 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
128 changes: 128 additions & 0 deletions
128
src/Controls/tests/TestCases.HostApp/Issues/Issue33510.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,128 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 33510, "[Android] RefreshView triggers pull-to-refresh immediately when scrolling up inside a WebView", PlatformAffected.Android)] | ||
| public class Issue33510 : TestContentPage | ||
| { | ||
| RefreshView _refreshView; | ||
| Label _statusLabel; | ||
|
|
||
| protected override void Init() | ||
| { | ||
| _statusLabel = new Label | ||
| { | ||
| AutomationId = "StatusLabel", | ||
| Text = "Loading..." | ||
| }; | ||
|
|
||
| var webView = new WebView | ||
| { | ||
| AutomationId = "TestWebView", | ||
| Source = new HtmlWebViewSource { Html = ScrollableHtml } | ||
| }; | ||
|
|
||
| webView.Navigated += (_, _) => _statusLabel.Text = "WebView ready"; | ||
|
|
||
| _refreshView = new RefreshView | ||
| { | ||
| AutomationId = "TestRefreshView", | ||
| Content = webView | ||
| }; | ||
|
|
||
| _refreshView.Command = new Command(async () => | ||
| { | ||
| _statusLabel.Text = "Refresh triggered"; | ||
| await Task.Delay(150); | ||
| _refreshView.IsRefreshing = false; | ||
| }); | ||
|
|
||
| var grid = new Grid | ||
| { | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| grid.Add(_statusLabel, 0, 0); | ||
| grid.Add(_refreshView, 0, 1); | ||
|
|
||
| Content = grid; | ||
| } | ||
|
|
||
| const string ScrollableHtml = """ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <style> | ||
| html, body { | ||
| margin: 0; | ||
| padding: 0; | ||
| height: 100%; | ||
| overflow: hidden; | ||
| font-family: sans-serif; | ||
| } | ||
|
|
||
| #wrapper { | ||
| height: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| #header { | ||
| position: sticky; | ||
| top: 0; | ||
| padding: 12px; | ||
| background: #f2f2f2; | ||
| border-bottom: 1px solid #d9d9d9; | ||
| font-weight: 600; | ||
| } | ||
|
|
||
| #scrollHost { | ||
| flex: 1; | ||
| overflow-y: auto; | ||
| -webkit-overflow-scrolling: touch; | ||
| padding: 12px; | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| .card { | ||
| margin-bottom: 12px; | ||
| padding: 12px; | ||
| border-radius: 8px; | ||
| background: #e8f0fe; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div id="wrapper"> | ||
| <div id="header">Issue33510 Internal Scroll Host</div> | ||
| <div id="scrollHost"> | ||
| <div class="card">Content 01</div> | ||
| <div class="card">Content 02</div> | ||
| <div class="card">Content 03</div> | ||
| <div class="card">Content 04</div> | ||
| <div class="card">Content 05</div> | ||
| <div class="card">Content 06</div> | ||
| <div class="card">Content 07</div> | ||
| <div class="card">Content 08</div> | ||
| <div class="card">Content 09</div> | ||
| <div class="card">Content 10</div> | ||
| <div class="card">Content 11</div> | ||
| <div class="card">Content 12</div> | ||
| <div class="card">Content 13</div> | ||
| <div class="card">Content 14</div> | ||
| <div class="card">Content 15</div> | ||
| <div class="card">Content 16</div> | ||
| <div class="card">Content 17</div> | ||
| <div class="card">Content 18</div> | ||
| <div class="card">Content 19</div> | ||
| <div class="card">Content 20</div> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| </html> | ||
| """; | ||
| } |
77 changes: 77 additions & 0 deletions
77
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33510.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,77 @@ | ||
| #if ANDROID // This test is Android-only because Issue #33510 (RefreshView triggering pull-to-refresh when scrolling inside a WebView) only reproduces on Android, and the test uses Android-specific Appium touch gesture APIs. | ||
| using NUnit.Framework; | ||
| using OpenQA.Selenium.Appium.Interactions; | ||
| using OpenQA.Selenium.Interactions; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| [Category(UITestCategories.RefreshView)] | ||
| public class Issue33510 : _IssuesUITest | ||
| { | ||
| const string StatusLabel = "StatusLabel"; | ||
| const string TestRefreshView = "TestRefreshView"; | ||
|
|
||
| public Issue33510(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "[Android] RefreshView triggers pull-to-refresh immediately when scrolling up inside a WebView"; | ||
|
|
||
| [Test] | ||
| public void PullToRefreshShouldNotTriggerWhenWebViewIsScrolledDown() | ||
| { | ||
| var androidApp = WaitForAndroidApp(); | ||
| var refreshViewRect = App.WaitForElement(TestRefreshView).GetRect(); | ||
| var x = refreshViewRect.CenterX(); | ||
|
|
||
| // Scroll content down by swiping up inside the WebView | ||
| for (var i = 0; i < 3; i++) | ||
| { | ||
| DragInsideWebView(androidApp, x, | ||
| refreshViewRect.Y + (refreshViewRect.Height * 70 / 100), | ||
| x, | ||
| refreshViewRect.Y + (refreshViewRect.Height * 25 / 100)); | ||
| } | ||
|
|
||
| // Attempt pull-to-refresh (drag down) while content is still scrolled down | ||
| DragInsideWebView(androidApp, x, | ||
| refreshViewRect.Y + (refreshViewRect.Height * 30 / 100), | ||
| x, | ||
| refreshViewRect.Y + (refreshViewRect.Height * 80 / 100)); | ||
|
|
||
| Assert.That(App.FindElement(StatusLabel).GetText(), Does.Not.Contain("Refresh triggered"), | ||
| "RefreshView should not trigger while WebView content is not at the top."); | ||
| } | ||
|
|
||
| AppiumAndroidApp WaitForAndroidApp() | ||
| { | ||
| if (App is not AppiumAndroidApp androidApp) | ||
| { | ||
| Assert.Ignore("Issue #33510 is Android-specific."); | ||
| return null!; | ||
| } | ||
|
|
||
| Assert.That( | ||
| App.WaitForTextToBePresentInElement(StatusLabel, "WebView ready", timeout: TimeSpan.FromSeconds(30)), | ||
| Is.True, | ||
| "WebView never finished loading."); | ||
|
|
||
| return androidApp; | ||
| } | ||
|
|
||
| static void DragInsideWebView(AppiumAndroidApp androidApp, int fromX, int fromY, int toX, int toY) | ||
| { | ||
| var touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch); | ||
| var dragSequence = new ActionSequence(touchDevice, 0); | ||
|
|
||
| dragSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, fromX, fromY, TimeSpan.Zero)); | ||
| dragSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact)); | ||
| dragSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, toX, toY, TimeSpan.FromMilliseconds(450))); | ||
| dragSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact)); | ||
|
|
||
| androidApp.Driver.PerformActions([dragSequence]); | ||
| } | ||
| } | ||
| #endif | ||
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.
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.