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] Modal shown TabbedPage has problems with SetSoftInputMode AdjustResize #20358

Open
siem300 opened this issue Feb 5, 2024 · 7 comments
Labels
area-controls-tabbedpage TabbedPage migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert p/2 Work that is important, but is currently not scheduled for release platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@siem300
Copy link

siem300 commented Feb 5, 2024

Description

During our migration of Maui from Xamarin Forms we ran into a problem where the TabbedPage renders its Toolbar across the content of the shown page. This only happens when the TabbedPage is opened as a Modal and SetSoftInputMode is set to AdjustResize in the MainActivity.

We need the AdjustResize to prevent the keyboard from blocking the input control when the user is typing.

I have attached a reproduction project and screenshots containing the error.

Modal TabbedPage Non modal TabbedPage
Screenshot_20240205-113440 Screenshot_20240205-113447

Steps to Reproduce

  1. Start the attached repro scenario
  2. Select the entry field, the resize happens and is shown correctly
  3. Select the 'Click me' button
  4. Select the entry field, the resize happens and the tabbedpage is now shown above the content

Link to public reproduction project repository

https://github.com/siem300/Maui-Modal-TabbedPage-issue

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

#20358 (comment)

Relevant log output

No response

@siem300 siem300 added the t/bug Something isn't working label Feb 5, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Feb 5, 2024
@ghost
Copy link

ghost commented Feb 5, 2024

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@jsuarezruiz jsuarezruiz added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Feb 5, 2024
@konradzuse
Copy link

I have a similar issue, my tabbed page is using a BottomNavBar, and the bar is stretched to fill half the screen when the keyboard opens

@siem300
Copy link
Author

siem300 commented Feb 20, 2024

The moment you give the tabbar a background color the problem gets worse cause you can't see the underlying content anymore.

@Uridel
Copy link

Uridel commented Feb 20, 2024

Is there any workaround for this issue. It is currently halting our product from being taken into production.

@PureWeen
Copy link
Member

alright so here's a workaround

#if ANDROID
            this.Children[0].Loaded += (_,_) =>
            {
                var platformView = (this.Handler as IPlatformViewHandler).PlatformView;                
                
                var bottomNavigationView = (platformView.Parent.Parent as Android.Views.View)
                    .FindViewById<Android.Views.ViewGroup>(Resource.Id.navigationlayout_bottomtabs)
					.GetChildAt(0);
                
				bottomNavigationView.SetPadding(0,0,0,0);
                AndroidX.Core.View.ViewCompat.SetOnApplyWindowInsetsListener(bottomNavigationView, null);

            };
#endif

Add this to the ctor of your tabbedpage that's being pushed modally.

This seems to be a weird quirk with BottomNavigationView

If you search around for BottomNavigationView and software keyboard you'll get a bunch of SO posts that tell you to use "AdjustPan" instead of "AdjustResize" to fix :-)

BottomNavigationView has this window inset watcher that bumps the navigationview up.
I haven't tested all scenarios to see if this breaks other things yet.

For NET9 I'm hoping that moving to DialogFragment just magically fixes this

image

@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Mar 14, 2024
@XamlTest
Copy link

Verified this on VS 17.10.0 Preview 2.0(8.0.7). Repro on Android 14.0-API34.
Maui-Modal-TabbedPage.zip

@siem300
Copy link
Author

siem300 commented Mar 14, 2024

@PureWeen The workaround works! Thanks for figuring out a temporary solution.

@PureWeen PureWeen added the p/2 Work that is important, but is currently not scheduled for release label Jun 15, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-tabbedpage TabbedPage migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert p/2 Work that is important, but is currently not scheduled for release platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants