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
Ignore ScrollRectToVisible if KeyboardAutoManagerScroll is enabled in ItemsViewController #19875
Ignore ScrollRectToVisible if KeyboardAutoManagerScroll is enabled in ItemsViewController #19875
Conversation
…ManagerScroll is enabled
Hey there @artemvalieiev! 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). |
Currently working on a UITest for this one! |
…ctionView-Header-gets-moved-on-input-field
@@ -316,7 +316,7 @@ internal static void AdjustPosition() | |||
nfloat statusBarHeight; | |||
nfloat navigationBarAreaHeight; | |||
|
|||
if (ContainerView.GetNavigationController() is UINavigationController navigationController) | |||
if (View.FindResponder<UINavigationController>() is UINavigationController navigationController) |
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.
Small change in my scrolling code here to use the current UINavigationController instead of the top-most one in case there are multiple UINavigationControllers. This presented an issue from building the UITest for this PR!
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.
Looks good, just have some qwuestions on the public API and new types being used.
|
||
namespace Microsoft.Maui.Platform; | ||
|
||
public class MauiCollectionView : UICollectionView |
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.
This is a new API and I am not sure what the rules are for servicing. Maybe this can be internal for now?
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.
You are right. There is no reason to have this “public”, I set it to “public” out of habit without thinking.
…CollectionView-Header-gets-moved-on-input-field
…ems from Controls.Core.Handlers.Items
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.
Looking good to me! Worth noting that the issue is present in Catalyst as well and this PR fixes the issue there as well
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Description of Change
Focusing on any input field placed in the header currently makes UICollectionView change its offset. I tried to find what exact method changes contentoffset/contentinset, but I was not able to find a reason until I checked NSThread.NativeCallStack to check who invokes SetContentOffset and noticed this
[23]: "23 UIKitCore 0x000000018560caa8 -[UITextField scrollTextFieldToVisibleIfNecessary] + 300"
[24]: "24 UIKitCore 0x000000018560cb70 -[UITextField becomeFirstResponder] + 164"
[UITextField scrollTextFieldToVisibleIfNecessary] is a private API method that is invoked internally in UIKit by Apple on becomeFirstResponder, which invokes ScrollToRect, which triggers SetContentOffset.
I wanted to avoid overriding ScrollToRectVisiblet. However, it is not used internally, and all scrolling happens directly by changing the content offset and doesn't affect snapping points, scrolling to the item, and other functionality. The only place that uses this ScrollToRectVisible in MAUI is in MauiScrollView that and does the same override to fix scroll behavior for input fields.
Issues Fixed
Fixes #10947
This issue also is present in XF xamarin/Xamarin.Forms#9879 xamarin/Xamarin.Forms#13927
Video
before
before_fix.mov
after
after_fix.mov