maui icon indicating copy to clipboard operation
maui copied to clipboard

iOS - Keyboard changes page layout, and doesn't always return back to normal

Open IeuanWalker opened this issue 1 year ago • 4 comments
trafficstars

Description

When the keyboard is opened the screen layout changes, when it closes, it doesn't always return back to the normal layout.

See in the below video, the next and back buttons are at the bottom of the screen, when the keyboard opens they are moved up, and sometimes get stuck -

https://github.com/user-attachments/assets/32e62f02-d536-454c-8b0d-3ea87526dfb6

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.90 SR9

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

IeuanWalker avatar Oct 10 '24 17:10 IeuanWalker

I have a similar issue with CollectionView. It only occurs when opening the keyboard causes a scroll bar to appear and there wasn't one before.

danylokl avatar Oct 10 '24 19:10 danylokl

@tj-devel709 here is the repo - https://github.com/IeuanWalker/Maui-iOS-Layout-issue-25185

Looks like the cause is if there is enough space above the editor that when the keyboard it opened it causes the scrollview to kick in.

In the repo there are 2 repos

  • Basic
    • This uses just Maui controls and the minimum to repo the issue
    • If you switch the red boxview and the editor around, you don't get the issue. Looks like it only happens when the editor is towards the bottom of the screen, and opening the keyboard triggeres the scrollview to scroll.
  • Full repo
    • This is the full layout used by our app
    • Seams a bit more glitchier than the basic version

Here is a vid showing the repo app - https://github.com/user-attachments/assets/5a6805a6-e02e-473c-aa59-a7aeea2ec5f2

You can see that the blue BoxView randomly gets stuck after the keyboard is opened, and doesn't return to the bottom.

IeuanWalker avatar Oct 15 '24 09:10 IeuanWalker

I can repro it at iOS platform on the latest 17.12.0 Preview 3.0(8.0.92 & 8.0.90).

jaosnz-rep avatar Oct 17 '24 07:10 jaosnz-rep

I confirm this exist in 8.0.92

smardine avatar Oct 24 '24 06:10 smardine

cc @tj-devel709

jsuarezruiz avatar Oct 28 '24 09:10 jsuarezruiz

@jsuarezruiz @tj-devel709 any update on this?

IeuanWalker avatar Nov 25 '24 21:11 IeuanWalker

I've just hit this issue on iOS, Android seems OK - do we have any workarounds?

dan5602 avatar Feb 05 '25 16:02 dan5602

None that i know of :/

First maui bug ive come across without any workaround, and its also the most impactful UX issue we've seen.

IeuanWalker avatar Feb 05 '25 22:02 IeuanWalker

Hi, same issue here on 9.0.40

michalpobuta avatar Feb 27 '25 11:02 michalpobuta

@IeuanWalker Here u have workaround:

public class CustomEntryHandler : EntryHandler
{
    protected override void ConnectHandler(MauiTextField platformView)
    {
        base.ConnectHandler(platformView);

        (VirtualView as Entry)!.Unfocused += OnUnfocused;
    }

    private void OnUnfocused(object? sender, FocusEventArgs e)
    {
        Element element = e.VisualElement;
        while (element is not Page)
        {
            element = element.Parent;
            if (element is ScrollView scrollView)
            {
                scrollView.InvalidateMeasure();
                return;
            }
        }
    }

    protected override void DisconnectHandler(MauiTextField platformView)
    {
        (VirtualView as Entry)!.Unfocused -= OnUnfocused;
        base.DisconnectHandler(platformView);
    }
}

michalpobuta avatar Feb 27 '25 13:02 michalpobuta