-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fix for Scrollview.ScrollTo execution only returns after manual scroll #28528
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
base: main
Are you sure you want to change the base?
[Windows] Fix for Scrollview.ScrollTo execution only returns after manual scroll #28528
Conversation
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where ScrollView.ScrollTo on Windows would not complete the operation when the requested offset matched the current offset, causing the await to wait indefinitely.
- Added automated tests for the issue in both shared tests and the host app.
- Updated the Windows ScrollViewHandler to immediately mark scrolling as finished when the requested offset matches the current offset.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15508.cs | Added a test that verifies the scroll operation completes as expected. |
src/Controls/tests/TestCases.HostApp/Issues/Issue15508.cs | Implemented a UI test demonstrating the scroll fix in the host app. |
src/Core/src/Handlers/ScrollView/ScrollViewHandler.Windows.cs | Updated scroll behavior to handle cases where the current offset matches the requested offset. |
Comments suppressed due to low confidence (2)
src/Controls/tests/TestCases.HostApp/Issues/Issue15508.cs:29
- [nitpick] Consider renaming the local variable _scrollButton to scrollButton for clarity, reserving the underscore prefix for private fields.
Button _scrollButton = new Button
src/Core/src/Handlers/ScrollView/ScrollViewHandler.Windows.cs:77
- [nitpick] If VerticalOffset and HorizontalOffset are floating point values, consider using an epsilon-based comparison to handle potential precision issues.
if (request.VerticalOffset == handler.PlatformView.VerticalOffset && request.HorizontalOffset == handler.PlatformView.HorizontalOffset)
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
|
||
[Test] | ||
[Category(UITestCategories.ScrollView)] | ||
public void ScrollViewinAwait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz, I have modified the test case and ensured that it passes when we include a slight delay.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/rebase |
0e54516
to
027055c
Compare
@@ -78,7 +78,14 @@ public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView sc | |||
{ | |||
if (args is ScrollToRequest request) | |||
{ | |||
handler.PlatformView.ChangeView(request.HorizontalOffset, request.VerticalOffset, null, request.Instant); | |||
if (request.VerticalOffset == handler.PlatformView.VerticalOffset && request.HorizontalOffset == handler.PlatformView.HorizontalOffset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, can extract the position comparison into a well-named boolean variable that clearly communicates its purpose:
bool isAlreadyAtRequestedPosition =
request.VerticalOffset == handler.PlatformView.VerticalOffset &&
request.HorizontalOffset == handler.PlatformView.HorizontalOffset;
if (isAlreadyAtRequestedPosition)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz, As suggested I have modified the changes
{ | ||
App.WaitForElement("Button"); | ||
App.Tap("Button"); | ||
Thread.Sleep(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove this waiting time to a method waiting until "Scroll Completed" appears with a maximum timeout.
WaitForTextToBePresentInElement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz, As suggested I have modified the changes
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Root Cause of the issue
Description of Change
Issues Fixed
Fixes #15508
Tested the behaviour in the following platforms
Output
Beforefix_scroll.mp4
Afterfix_scroll.mp4