Skip to content
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

Adding ContentInsets to iOS Keyboard Scrolling #14371

Merged
merged 6 commits into from
May 2, 2023

Conversation

tj-devel709
Copy link
Member

@tj-devel709 tj-devel709 commented Apr 3, 2023

Description of Change

Maui iOS does not apply any ContentInsets to the appropriate scrolling view when the screen scrolls up for the keyboard. While this is not a regression from the new Keyboard Scrolling feature, IQKeyboard does handle this and will allow us to focus an entry or editor, scroll around the page (with the keyboard still up) and still be able to scroll back down and see our focused view.

IQKeyboard has logic here to update the ContentInset when we scroll for the keyboard.
This PR brings over this functionality.

iOSInsetBehavior.mov

Issues Fixed

Fixes #14043

@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 3, 2023
@tj-devel709
Copy link
Member Author

Please note, when we click an entry or editor that does not require the screen to scroll (the last part of the demo in the description), there is no ContentInset added to the scrollview and we cannot reach the bottom of the scrollview. It is most likely possible to still add this ContentInset to every Entry and Editor inside a scrollview, however, this PR reflects how Android handles this situation as shown in this video below. Let me know if there are concerns or opinions on which way is best to handle this.

AndroidScrollingInsets.mov

@rmarinho
Copy link
Member

rmarinho commented Apr 5, 2023

Did you tested with a CollectionView with entries ?

@tj-devel709
Copy link
Member Author

Did you tested with a CollectionView with entries ?

@ruiminhu I have not, but I'll give it a shot today!

@tj-devel709
Copy link
Member Author

Did you tested with a CollectionView with entries ?

Did run into some issues with collectionview and spending more time investigating them!

@tj-devel709
Copy link
Member Author

@ruiminhu there were some changes needed from IQKeyboard since I changed some of the scrolling behavior to fit MAUI's controllers better. Looks good to me now with Collectionview! (android for comparison)

iOSCollectionViewInset.mov
AndroidCollectionViewInsets.mov

@tj-devel709 tj-devel709 marked this pull request as ready for review April 11, 2023 18:52
@rmarinho
Copy link
Member

Why do the scrolls have a large padding (inset) in the beginning on your videos? What's the sample code for that example?

@tj-devel709
Copy link
Member Author

Why do the scrolls have a large padding (inset) in the beginning on your videos? What's the sample code for that example?

Hey @ruiminhu, yeah I just had an empty boxview to test having the items towards the bottom of the screen. Here is the sample code:
https://gist.github.com/tj-devel709/4830ccaa3cbbb97de9df0b2ffb622ba0

@rmarinho rmarinho merged commit abc42d2 into dotnet:main May 2, 2023
@SarthakB26
Copy link

SarthakB26 commented Jun 27, 2023

@tj-devel709 why we are putting CollectionView in ScrollView In you sample?. Shouldn't we could add ContentInset to Collectiontion view if entry which is opening a keyboard is inside CollectionView in case of iOS.

I was able to do that previously I couldn't find the code but I was subscribing to KeyboardOpen event and checking if keyboard would overlap entry in that case I was adding appropriate ContentInset to CollectionView.

My requirement was different though I was having Editor(AutoSize=true) inside CollectionView. The issue in this I was having was since Editor AutoSize was true when user writing long multiple line text, after adding few line editor would go under the keyboard after this user cannot see what he was typing. Yes user can scroll up the collection view manually with interaction but still customer was not happy with the behviour in iOS. On Android though collection view was moving up automatically on every next line if editor is about to go under keyboard.

I hope you make sure of this editor expanding behaviour atleast in ScrollView(Without CollectionView).

@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2023
@samhouts samhouts added backport/approved After some discussion or review, this PR or change was approved to be backported. and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels Jan 31, 2024
@samhouts samhouts added the fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-entry Entry area-keyboard Keyboard, soft keyboard backport/approved After some discussion or review, this PR or change was approved to be backported. fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] After lower positioned text entry item selected and scrolled, you can't scroll back to it.
5 participants