unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.87k stars 716 forks source link

Nested MenuFlyout (MenuFlyoutSubItem) LightDismiss Freezes the UI #4795

Closed robloo closed 1 year ago

robloo commented 3 years ago

Current behavior

With nested MenuFlyoutItems (example below) the flyouts show correctly. However, if no selection is made and a click is made outside the flyout (to light dismiss) the flyout stays open. The UI locks up and no press is received anywhere else, even on the menu items.

Note that this issue only occurs when the MenuFlyoutSubItem is open.

                    <Button.Flyout>
                        <MenuFlyout
                            Placement="Bottom">
                            <MenuFlyoutItem />
                            <MenuFlyoutSeparator />
                            <MenuFlyoutItem />
                            <MenuFlyoutSubItem>
                                <MenuFlyoutSubItem.Icon>
                                    <FontIcon  />
                                </MenuFlyoutSubItem.Icon>
                                <MenuFlyoutItem  />
                            </MenuFlyoutSubItem>
                        </MenuFlyout>
                    </Button.Flyout>

Expected behavior

Should LightDismiss, no lockup

How to reproduce it (as minimally and precisely as possible)

See above

Workaround

None

Environment

Nuget Package:

Nuget Package Version(s): 3.4.0

Affected platform(s):

IDE:

Relevant plugins:

Anything else we need to know?

robloo commented 3 years ago

Possibly fixed by #5640, will test when I get a chance

MartinZikmund commented 3 years ago

@robloo were you able to retest this sometime?

robloo commented 3 years ago

Not yet, I'm still on an older 3.6.x build and was waiting for 3.8 to do another round of testing.

(I'm also hoping the VS issues get fixed so Uno builds again without a host of issues)

robloo commented 3 years ago

Tested again with 3.8.6 and the issue is still present. Light dismiss of a MenuFlyoutSubItem will completely freeze the UI.

robloo commented 3 years ago

So this issue no longer crashes the app. However, it is impossible to light dismiss a MenuFlyoutSubItem. The menu flyout simply will not close if you click outside of the menu. The only way to close the menu once the MenuFlyoutSubItem is opened is to make a selection.

Note that this issue doesn't happen for MenuFlyoutItem which works correctly. It is only in nested menus.

jeromelaban commented 3 years ago

Have you tried disabling native popups? This is likely related.

robloo commented 3 years ago

I made sure to disable native popups using:

<Button.Flyout>
  <MenuFlyout
    Placement="Bottom"
    not_win:UseNativePopup="False">
     <!-- elements removed -->
  </MenuFlyout>
</Button.Flyout>

and also in the App constructor just in case:

        public App()
        {
            this.InitializeComponent();

#if !NETFX_CORE
            // For Uno Platform apps, make sure to configure UWP styles instead of platform-native
            Uno.UI.FeatureConfiguration.Style.UseUWPDefaultStyles = true;
#endif
        }

Functionality was not changed:

asdfasdf

Youssef1313 commented 3 years ago

https://github.com/unoplatform/uno/blob/d97a9b606a201857bd514fdacd1bc95fb70604a7/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutSubItem.cs#L274

Changing this to true causes the item to be light dismissed correctly. But light dismiss doesn't delegate to parents (ie, you'll have to do multiple clicks to completely dismiss the whole menu. Every click dismisses the inner-most open child)

dr1rrb commented 3 years ago

https://github.com/unoplatform/uno/blob/d97a9b606a201857bd514fdacd1bc95fb70604a7/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutSubItem.cs#L274

Changing this to true causes the item to be light dismissed correctly. But light dismiss doesn't delegate to parents (ie, you'll have to do multiple clicks to completely dismiss the whole menu. Every click dismisses the inner-most open child)

The dismiss-layer is handle directly Popup level (https://github.com/unoplatform/uno/blob/master/src/Uno.UI/UI/Xaml/Controls/Popup/Popup.cs#L78) while it should be handled PopupRoot and/or PopupPanel, and clicking out of popups should dismiss all of them at once. Wondering however what is the behavior if a open a dismissable and a non dismissable popup and the same time.

GitHub
uno/Popup.cs at master · unoplatform/uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported. - uno/Popup.cs at master · unoplatform/uno
ramezgerges commented 1 year ago

This doesn't reproduce and is tested in https://github.com/unoplatform/uno/blob/master/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutTests/MenuFlyoutTests.cs#L202.