question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hovering over AppBarButton and then quickly going to CommandBarFlyout submenu hides submenu

See original GitHub issue

Steps to reproduce the bug

  1. Create an app with following XAML:
        <Button Content="Button1">
            <Button.Flyout>
                <CommandBarFlyout>
                    <CommandBarFlyout.SecondaryCommands>
                        <AppBarButton Label="AppBarButton1">
                            <AppBarButton.Flyout>
                                <MenuFlyout>
                                    <MenuFlyoutItem Text="Item 1"/>
                                </MenuFlyout>
                            </AppBarButton.Flyout>
                        </AppBarButton>
                        <AppBarButton Label="AppBarButton2">
                        </AppBarButton>
                    </CommandBarFlyout.SecondaryCommands>
                </CommandBarFlyout>
            </Button.Flyout>
        </Button>
  1. Run the app
  2. Click button
  3. Hover over the AppBarButton with a submenu.
  4. Hover over the other AppBarButton and then quickly hover over the submenu.

Expected behavior I’d expect the submenu to stay open, but instead it closes. It does if you use a MenuFlyout instead of CommandBarFlyout for the top level menu.

Screenshots Here’s a video of the bug:

https://user-images.githubusercontent.com/359157/128073649-93be0d03-6814-49f5-897b-c0add0ee9779.mov

Here’s a video of the same setup using MenuFlyout instead of CommandBarFlyout, showing that it doesn’t have this bug:

https://user-images.githubusercontent.com/359157/128073839-c70d5c8c-e3a8-4f72-9c9a-40847d8560e0.mov

Version Info Windows 10 21H1 / 19043

Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context The bug seems to be in AppBarButton.OnPointerEntered. It schedules a timer to hide any open submenus. That timer should get cancelled if the user hovers over the submenu.

A workaround is to add a PointerEntered event on the MenuFlyoutItems in the submenu with the following code:

      menuItem.PointerEntered(
          [parentButton](auto const& /*sender*/, winrt::Input::PointerRoutedEventArgs const& e) {
            parentButton.OnPointerEntered(e);
          });

EDIT: The workaround has a bug. See https://github.com/microsoft/microsoft-ui-xaml/issues/5617#issuecomment-895630516.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lyahdavcommented, Aug 7, 2021

Thanks, I just checked and it’s UAP version 14.

1reaction
StephenLPeterscommented, Aug 6, 2021

No, unfortunately a fix for Windows 10 versions wont be possible. I would recommend an IsApiContractPresent check like this: https://github.com/microsoft/microsoft-ui-xaml/blob/8b7e40a7e8848b62052e63ad9616f66e2763b4a7/dev/dll/SharedHelpers.cpp#L230 to wrap your work around in. I believe the UAP version for this is 15…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hiding dropdown menu on hover issues
I have a sub menu within a menu that doesn't work as intended, it simply needs to be shown when hovered over and...
Read more >
Command bar flyout - Windows apps
The command bar flyout lets you provide users with easy access to common tasks by showing commands in a floating toolbar related to...
Read more >
How to solve the diagonal submenu hover problem
The main problem with the “hover parent, toggle children” approach is that as soon as the cursor leaves the parent item then the...
Read more >
Unable to click on sub menu on hovering - Help
Hi , i have to click on an element that is visible on hover. ... my recorder gets active after pressing F2, the...
Read more >
How to create submenu that appears "While Hovering"
I can get the submenu variants to display when I “Mouse enter” the top items, but if you don't move to the submenu...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found