From 044b31958fbabd9d690d0548a941aed0c4e842b0 Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Wed, 4 Sep 2024 14:35:35 +0300 Subject: [PATCH] fix: do not close manual tooltip on target mousedown (#7746) * fix: do not close manual tooltip on target mousedown * fix: make menu-bar tooltip close immediately on mousedown --- packages/menu-bar/src/vaadin-menu-bar-mixin.js | 2 +- packages/tooltip/src/vaadin-tooltip-mixin.js | 4 ++++ packages/tooltip/test/tooltip.common.js | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/menu-bar/src/vaadin-menu-bar-mixin.js b/packages/menu-bar/src/vaadin-menu-bar-mixin.js index d7913f3230..09cac21d8b 100644 --- a/packages/menu-bar/src/vaadin-menu-bar-mixin.js +++ b/packages/menu-bar/src/vaadin-menu-bar-mixin.js @@ -250,7 +250,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)); diff --git a/packages/tooltip/src/vaadin-tooltip-mixin.js b/packages/tooltip/src/vaadin-tooltip-mixin.js index 0e8a7a8300..ed9309f041 100644 --- a/packages/tooltip/src/vaadin-tooltip-mixin.js +++ b/packages/tooltip/src/vaadin-tooltip-mixin.js @@ -653,6 +653,10 @@ export const TooltipMixin = (superClass) => /** @private */ __onMouseDown() { + if (this.manual) { + return; + } + this._stateController.close(true); } diff --git a/packages/tooltip/test/tooltip.common.js b/packages/tooltip/test/tooltip.common.js index b9b5e83785..c3b1f90243 100644 --- a/packages/tooltip/test/tooltip.common.js +++ b/packages/tooltip/test/tooltip.common.js @@ -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;