[ContextualMenu] Cannot open submenu when hover if the first menu item has submenu
Environment Information
- Package version(s): 7.168.2 and 8
- Browser and OS versions: chrome, edge-chromium
Please provide a reproduction of the bug in a codepen:
https://codepen.io/jieqiu0129/pen/eYvjyVL
Actual behavior:
When open the context menu, then hover the parent menu item directly, the submenu cannot be shown. Only by clicking on the item or move out the mouse and re-hover, the submenu will be opened.
Expected behavior:
Should show submenu when hovering parent item.
@jieqiu0129 - Thanks for reaching out and submitting this issue with the codepen.
@ling1726 - Would you be able to confirm if this is a regression, or if this behavior is an issue?
@jieqiu0129 This is a bug for ContextualMenu. As workarounds you can:
- use the
DefaultButtonvariant withmenuPropswhich will work. - use
shouldFocusOnMount={false}in your example to make it work. Here is a repro of this workaround here: https://codesandbox.io/s/interesting-https-wt869?file=/src/App.js, however you should managed focus appropriately for your a11y
From first investigation it seems that the difference between using ContextualMenu and DefaultButton with menu, is that when ContextualMenu is opened, the first menu item is focused, which stops mouse hover from opening the submenu. In the DefaultButton variant the entire menu is focused on open, and not the first menuitem.
@gouttierre please triage for someone in the v8 team to investigate this bug
@ling1726 Thanks for your investigation! The workaround work for me
@ling1726 by using shouldFocusOnMount={false} and having few ContextualMenus on a page, when one is open and you click to open another one, the former is remaining open..