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: Control (Like Entry) don't work coming back when using Mopups to transition between two pages. #93

Closed
DigitalNut opened this issue Nov 7, 2023 · 7 comments

Comments

@DigitalNut
Copy link

DigitalNut commented Nov 7, 2023

Use the basic Maui sample app in Visual Studio to test this. Add Mopups NuGet package

  1. Create a page (Page1) with an Entry control
  2. Create a second page (Page2)
  3. Create a basic popup page
  4. On page1 setup an action to popup the basic popup (e.g. MopupService.Instance.PushAsync(BusyPopup, false);). Also add control/action to go to Page2 after the popup.
  5. On Page2, close the popup (MopupService.Instance.PopAsync(true);) in OnAppearing() . Also add a way to go back to page 1. If using the Maui sample app, this should be done for you

Sample project to reproduced this issue:
MauiMopupsTest.zip

Now when you run the program, notice that you can input text into the Entry control. Next press the button to go to page 2. This should bring up the popup and when page 2 is loaded the popup should disappear. Now press the button to go back to page 1. Press/touch the Entry control. Notice that the Entry control does not receive focus and no soft keyboard shows up.

The issue is caused by the setting of DescendantFocusability property in HandleAccessibility (AndroidMopups.cs).
I noticed that RG.Plugins.Popup does not set this property. The closing of the popup causes this flag to be reset on current page, which is Page2. But the popup was brought up from Page1, which HandleAccessibility will set this to DescendantFocusability.BlockDescendants. So when you go back to Page1, the Entry control is blocked.

We use this mechanism to bring up a busy popup for long tasks (load resources) than load the next page (as the page can be complex which takes time to load on some phones).

Is this property change required? Can a flag / option be used to control this behavior in the future?

One work around is to close the popup between page changes. Another work around (not modifing Mopups) is to add this code to your page that requires input, then on the OnAppearing() function call function:

Note: Add #if ANDROID around function

using Android.Views;

private void FixMopups()
{
    Page? mainPage = pageToFix; // Application.Current?.MainPage;

    if (mainPage == null)
        return;

    var view = mainPage.Handler?.PlatformView;// as Android.Views.View;
    if (view == null)
        return;

    ((ViewGroup)view).DescendantFocusability = DescendantFocusability.AfterDescendants;
}
@christianrr
Copy link

christianrr commented Nov 8, 2023

OMG, it took me hours to figure out what grabs the focus of the Entries in my Maui Android App.
@DigitalNut Many thanks for the hint and providing the workaround, this works well for the moment.

In our App, we have a small permanently visible popup with CloseWhenBackgroundIsClicked="False" BackgroundColor="Transparent" BackgroundInputTransparent="True" In this case it does not make sense at all that DescendantFocusability is set to BlockDescendants.

Some sort of flag would be a good idea IMO.

@IeuanWalker
Copy link
Contributor

@DigitalNut could you put together a small repo, will take a look

@IeuanWalker
Copy link
Contributor

IeuanWalker commented Nov 8, 2023

@christianrr not quite sure what your use case is here

If you have a popup permanently on top of ur content then people won't be able to interact with the content behind it.

Removing the accessibility handling would mean people using the screen reader on will be able to interact with the stuff behind the popup

So youd end up with people having different levels of interactivity.

But we could relatively easily add a DisableAccessibilityHandling flag, just not sure if its necessary

@christianrr
Copy link

@IeuanWalker We use a popup for a custom (styled) tab bar, which overlays all Shell pages and allows for animations of the tab bar on page transitions. All content pages have set a padding accordingly. As overriding the tab bar appearance of Maui Shell is not an easy one, this "workaround" works perfectly for us. The interaction with page content works well.

Find a repo attached:
MopupsFocusIssue.zip

@DigitalNut
Copy link
Author

@IeuanWalker Sample project is attached in above reported issue.

@IeuanWalker
Copy link
Contributor

@DigitalNut this should be fixed once the linked PR is merged and released.

@christianrr once the linked PR is merged and released, there will be a new property you can add too your popup DisableAndroidAccessibilityHandling.

@LuckyDucko
Copy link
Owner

Excellent work @IeuanWalker merged it in. Lets hope it sorts it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants