Skip to content

Commit dbebe59

Browse files
authored
fix: do not close slotted tooltip on overlay mousedown (#10259)
1 parent f6571da commit dbebe59

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/tooltip/src/vaadin-tooltip-mixin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,17 @@ export const TooltipMixin = (superClass) =>
553553
}
554554

555555
/** @private */
556-
__onMouseDown() {
556+
__onMouseDown(event) {
557557
if (this.manual) {
558558
return;
559559
}
560560

561+
// Do not close on bubbling mousedown events when
562+
// the tooltip is slotted into the target element
563+
if (event.composedPath().includes(this)) {
564+
return;
565+
}
566+
561567
this._stateController.close(true);
562568
}
563569

test/integration/component-tooltip.test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from '@vaadin/chai-plugins';
22
import { resetMouse, sendKeys, sendMouseToElement } from '@vaadin/test-runner-commands';
3-
import { fixtureSync, nextRender, tabKeyDown } from '@vaadin/testing-helpers';
3+
import { fixtureSync, mousedown, nextRender, tabKeyDown } from '@vaadin/testing-helpers';
44
import './not-animated-styles.js';
55
import { AccordionPanel } from '@vaadin/accordion/src/vaadin-accordion-panel.js';
66
import { Button } from '@vaadin/button/src/vaadin-button.js';
@@ -153,6 +153,15 @@ before(() => {
153153
}
154154
});
155155

156+
it('should not close slotted tooltip on overlay mousedown', () => {
157+
mouseenter(tooltip.target);
158+
159+
expect(tooltipOverlay.opened).to.be.true;
160+
const content = tooltip.querySelector('[slot="overlay"]');
161+
mousedown(content);
162+
expect(tooltipOverlay.opened).to.be.true;
163+
});
164+
156165
it('should set has-tooltip attribute on the element', () => {
157166
expect(element.hasAttribute('has-tooltip')).to.be.true;
158167
});

0 commit comments

Comments
 (0)