maui icon indicating copy to clipboard operation
maui copied to clipboard

MAUI Android Flyout Menu: Opening the Flyout Menu programmatically does not work correctly.

Open lauchacarro opened this issue 2 years ago • 5 comments
trafficstars

Description

When I want to open the Flyout menu programmatically by clicking on a button. It does not work.

You have to manually open the menu for the first time and then it just works programmatically.

Steps to Reproduce

  1. Clone https://github.com/lauchacarro/Maui-FlyoutMenu-Programmatically

  2. Run Androd Project

  3. First click twice on button 1 and you will see that nothing happens.

  4. Now click once on button 2 and you will see the flyout menu open.

If you see the code in MainPage.xaml.cs, you will know why one button works and another does not.

Practically, there must be a UI interaction before using FlyoutIsPresented.

Link to public reproduction project repository

https://github.com/lauchacarro/Maui-FlyoutMenu-Programmatically

Version with bug

7.0 (current)

Last version that worked well

7.0 (current)

Affected platforms

Android

Affected platform versions

Android 21

Did you find any workaround?

Add an invisible label in MainPage.xaml

Then, in the button click event, edit the label text before using the FlyoutIsPresented property.

Relevant log output

No response

lauchacarro avatar Feb 09 '23 19:02 lauchacarro

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Feb 13 '23 15:02 ghost

@lauchacarro thank you for the workaround! I too have this issue and your workaround did the trick. Hopefully this gets fixed in an expedited manner.

C0D3On3 avatar Feb 24 '23 20:02 C0D3On3

Hi, @lauchacarro It may be the same issue as Issue #8226. If it is the same case, you can avoid it with the following code. I was also in trouble with the same Issue.

Shell.Current.FlyoutBehavior = FlyoutBehavior.Locked;
Shell.Current.FlyoutBehavior = FlyoutBehavior.Flyout;
Shell.Current.FlyoutIsPresented = true;

cat0363 avatar Mar 27 '23 07:03 cat0363

Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. This issue does not repro on Windows 11 and iOS 16.4, repro on Android 13.0-API33 with below Project: 13233.zip

XamlTest avatar Jun 20 '23 10:06 XamlTest

My small and shorter modification of the workaround in #8226

bool alreadyOpen = false;
#if ANDROID
        if (!alreadyOpen)
        {
            Shell.Current.FlyoutBehavior = FlyoutBehavior.Flyout;
            alreadyOpen = true;
            Shell.Current.FlyoutBehavior = FlyoutBehavior.Disabled;
        }
#endif

        Shell.Current.FlyoutIsPresented = !Shell.Current.FlyoutIsPresented;

LeoKhariton avatar Feb 20 '24 18:02 LeoKhariton