-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix the OnNavigatedTo event and the OnAppearing event to return the ScrollToAsync method call #16619
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?
Conversation
|
Hey there @cat0363! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I wrote the unit test code. |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@rmarinho , Thank you for letting me know. Below are the verification results. [iOS]
On iOS, calling the ScrollToAsync method in the OnNavigatedTo and OnAppearing events when the screen is first displayed does not work as intended. [Android]
On Android, calling the ScrollToAsync method in the OnNavigatedTo and OnAppearing events when the screen is first displayed does not work as intended. [Windows]
On Windows, calling the ScrollToAsync method in the OnNavigatedTo and OnAppearing events when the screen is first displayed does not work as intended. Calling the ScrollToAsync method in the OnAppearing event when transitioning from another screen does not work as intended. All in all, the result was not what I expected. The PR I created shows that the ScrollToAsync method works as intended even when the screen is displayed for the first time. |
|
With 5af60d3, the problem is still there. Is there any other solution? |
|
Even with .NET 8, the problem continues to occur. |
|
@rmarinho , As far as I investigated, the method call does not finish only if the ScrollToAsync method is called when the ScrollView's size is not determined. |
|
Can you rebase on main I will pull and take a look |
|
Modify the previous code and upload it again. |
|
I made some changes today, but I'll revert to the latest version of main. It's probably the same problem as the one below. |
|
The latest code verification results for main are listed below. On Windows, if the call to the ScrollToAsync method does not change the position of the ScrollBar, the call to the ScrollToAsync method does not finish. Therefore, in addition to the latest source code for main, you will need: [src\Core\src\Handlers\ScrollView\ScrollViewHandler.Windows.cs] On iOS, calling the ScrollToAsync method within the OnNavigatedTo, OnAppearing events works as intended. On Android, calling the ScrollToAsync method within the OnNavigatedTo, OnAppearing event does not work as intended only on first appearance. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
…crollToAsync method call # Conflicts: # src/Controls/src/Core/ScrollView/ScrollView.cs
00adbd6 to
39d4332
Compare
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run MAUI-DeviceTests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
The test seems to fail on Android and that even crashes the test suite. I think the fix is good though. |
This PR fixes the problem that the call does not return when the ScrollToAsync method is
called at the timing of OnNavigatedTo, OnAppearing events.
Description of Change
If the ScrollToAsync method is called in the OnNavigatedTo or OnAppearing event, the Handler is null
at this point, so I added code to handle the scroll request in the Loaded event.
[src\Controls\src\Core\ScrollView\ScrollView.cs]
On Windows, the ViewChanged event doesn't fire until the ScrollView's position is updated, so I added code to call the ScrollFinish method if the requested scroll position is the same as the current scroll position when processing a scroll request.
[src\Core\src\Handlers\ScrollView\ScrollViewHandler.Windows.cs]
Issues Fixed
Fixes #15387
I used the following code for testing.
https://github.com/cat0363/Maui-IssueScrollToAsync2.git
The following log is output to the Editor before and after calling the ScrollToAsync method.
Below is the execution result.
[iOS]
iPhone.14.iOS.16.4.2023-08-09.12-08-31.mp4
iPhone.14.iOS.16.4.2023-08-09.12-43-59.mp4
[Android]
Android.Emulator.-.pixel_2_-_api_30_5554.2023-08-09.12-11-58.mp4
Android.Emulator.-.pixel_2_-_api_30_5554.2023-08-09.12-47-30.mp4
[Windows]
2023-08-09.12-05-21.mp4
2023-08-09.12-26-53.mp4
You can see that the ScrollToAsync method call is returned in the OnNavigatedTo event and OnAppearing event on all platforms.
The log is already displayed when the screen is started, but it is the log when the ScrollToAsync method is called in the OnNavigateTo event and OnAppearing event that is called when the screen is displayed for the first time.