Skip to content

Commit 54b6709

Browse files
authored
fix: do not close submenu on hovering button without items (#10274) (#10279)
1 parent f59a296 commit 54b6709

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
@@ -878,11 +878,11 @@ export const MenuBarMixin = (superClass) =>
878878
// Hide tooltip on mouseover to disabled button
879879
this._hideTooltip();
880880
} else if (button !== this._expandedButton) {
881-
const isOpened = this._subMenu.opened;
882-
if (button.item.children && (this.openOnHover || isOpened)) {
881+
// Switch sub-menu when moving cursor over another button
882+
// with children, regardless of whether openOnHover is set.
883+
// If the button has no children, keep the sub-menu opened.
884+
if (button.item.children && (this.openOnHover || this._subMenu.opened)) {
883885
this.__openSubMenu(button, false);
884-
} else if (isOpened) {
885-
this._close();
886886
}
887887

888888
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
@@ -525,12 +525,12 @@ describe('open on hover', () => {
525525
expect(subMenu.listenOn).to.equal(buttons[0]);
526526
});
527527

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

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

0 commit comments

Comments
 (0)