Skip to content

Commit 0e8bcde

Browse files
authored
fix: do not close submenu on hovering button without items (#10274)
1 parent d87dfda commit 0e8bcde

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/menu-bar/src/vaadin-menu-bar-mixin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,11 @@ export const MenuBarMixin = (superClass) =>
873873
// Hide tooltip on mouseover to disabled button
874874
this._hideTooltip();
875875
} else if (button !== this._expandedButton) {
876-
const isOpened = this._subMenu.opened;
877-
if (button.item.children && (this.openOnHover || isOpened)) {
876+
// Switch sub-menu when moving cursor over another button
877+
// with children, regardless of whether openOnHover is set.
878+
// If the button has no children, keep the sub-menu opened.
879+
if (button.item.children && (this.openOnHover || this._subMenu.opened)) {
878880
this.__openSubMenu(button, false);
879-
} else if (isOpened) {
880-
this._close();
881881
}
882882

883883
if (button === this._overflow || (this.openOnHover && button.item.children)) {

packages/menu-bar/test/sub-menu.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,12 @@ describe('open on hover', () => {
522522
expect(subMenu.listenOn).to.equal(buttons[0]);
523523
});
524524

525-
it('should close open sub-menu on mouseover on button without nested items', async () => {
525+
it('should not close open sub-menu on mouseover on button without nested items', async () => {
526526
fire(buttons[0], openOnHoverEvent);
527527
await nextRender();
528528
fire(buttons[1], openOnHoverEvent);
529529
await nextRender();
530-
expect(subMenu.opened).to.be.false;
530+
expect(subMenu.opened).to.be.true;
531531
});
532532

533533
it('should switch opened sub-menu on hover also when open-on-hover is false', async () => {

0 commit comments

Comments
 (0)