Skip to content

Commit

Permalink
fix: do not close manual tooltip on target mousedown (#7746)
Browse files Browse the repository at this point in the history
* fix: do not close manual tooltip on target mousedown

* fix: make menu-bar tooltip close immediately on mousedown
  • Loading branch information
web-padawan authored and vaadin-bot committed Sep 4, 2024
1 parent db3b6a8 commit 0ad3675
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/menu-bar/src/vaadin-menu-bar-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export const MenuBarMixin = (superClass) =>
});
this.addController(this._overflowController);

this.addEventListener('mousedown', () => this._hideTooltip());
this.addEventListener('mousedown', () => this._hideTooltip(true));
this.addEventListener('mouseleave', () => this._hideTooltip());

this._subMenu.addEventListener('item-selected', this.__onItemSelected.bind(this));
Expand Down
4 changes: 4 additions & 0 deletions packages/tooltip/src/vaadin-tooltip-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ export const TooltipMixin = (superClass) =>

/** @private */
__onMouseDown() {
if (this.manual) {
return;
}

this._stateController.close(true);
}

Expand Down
6 changes: 6 additions & 0 deletions packages/tooltip/test/tooltip.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,12 @@ describe('vaadin-tooltip', () => {
expect(overlay.opened).to.be.true;
});

it('should not close overlay on target mousedown', () => {
tooltip.opened = true;
mousedown(target);
expect(overlay.opened).to.be.true;
});

it('should close overlay when opened is set to false', () => {
tooltip.opened = true;

Expand Down

0 comments on commit 0ad3675

Please sign in to comment.