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

[Android] Window currently doesn't apply AdjustPan so the view doesn't pan up (scroll) when the keyboard opens #11274

Closed
PureWeen opened this issue Nov 10, 2022 · 6 comments · Fixed by #11356
Assignees
Labels
area-keyboard Keyboard, soft keyboard fixed-in-7.0.52 Look for this fix in 7.0.52 SR1.1! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/android 🤖

Comments

@PureWeen
Copy link
Member

PureWeen commented Nov 10, 2022

Description

Original issue here

In XF Window.SetSoftInputMode(Android.Views.SoftInput.AdjustPan); would get called after the OnCreate call whereas in MAUI it's called before OnCreate. It seems like this causes the property to have no effect

If you call this method after OnCreate than everything starts to work like XF.

Reproduction

If you take the XAML below and test a few different permutations, you'll notice that the behavior isn't currently consistent when you open a keyboard

  • Shell: Nothing happens
  • Shell/ScrollView: entry scrolls into view but ScrollView doesn't reset
  • NavigationPage/ScrollView: entry scrolls into view but ScrollView doesn't reset

If you test this scenario on XF all permutations work the same

  • the window pans up (scrolls up) when you open the keyboard
  • you close the keyboard and it pans back down
<StackLayout Padding="10">
            <Entry Text="Top"></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry Text="Middle"></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry></Entry>
            <Entry Text="Bottom"></Entry>
        </StackLayout>

Workaround

Install the nuget here

or

Copy the handler and associated code from here into your code

@Syed-RI
Copy link

Syed-RI commented Nov 10, 2022

@PureWeen thanks a lot !!! Really appreciate your hard work.

@solayuta
Copy link

@PureWeen Good This has solved the problem that has plagued me for a month. I even want to give up maui

@borrmann
Copy link
Contributor

Is there a workaround if you want certain behaviour on certain pages? I call this method sometimes in OnAppearing or OnNavigatedTo, but the behaviour doesn't update.

@PureWeen
Copy link
Member Author

@borrmann once this releases you should be able to change the platform specific for this on Application and it will update.

https://learn.microsoft.com/en-us/dotnet/maui/android/platform-specifics/soft-keyboard-input-mode?view=net-maui-7.0

@cerkzil
Copy link

cerkzil commented Dec 3, 2022

AdjustPan doesn't solve the problem completely, if the input doesn't need to be panned to input text it works, but if it pans it still causes the same issue
image

@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2023
@samhouts samhouts added fixed-in-7.0.52 Look for this fix in 7.0.52 SR1.1! fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! labels Feb 16, 2023
@PureWeen
Copy link
Member Author

PureWeen commented Mar 7, 2023

@cerkzil this should be fixed in a future release by #12661

I have a workaround in a nuget here
https://github.com/PureWeen/ShanedlerSamples

If you want to try that nuget and see if it fixes it for you. If it doesn't let me know and I can attach a repro.

@samhouts samhouts added fixed-in-7.0.101 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 backport/approved After some discussion or review, this PR or change was approved to be backported. labels Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-keyboard Keyboard, soft keyboard fixed-in-7.0.52 Look for this fix in 7.0.52 SR1.1! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/android 🤖
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants