Skip to content

Commit e265def

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Don't show tooltip if hover is a drag
Note: This does not fix the behavior that the text of a tooltip is being selected if the anchor had an active text selection before hovering. Change-Id: I15135dfbb040ef60af83b00ac14df38c59d522f8 Bug: 409988275 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6448276 Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Philip Pfaffe <[email protected]>
1 parent d6ab960 commit e265def

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

front_end/ui/components/tooltips/Tooltip.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ describe('Tooltip', () => {
9595
assert.isFalse(container.querySelector('devtools-tooltip')?.open);
9696
});
9797

98+
it('should not be activated if dragged', async () => {
99+
const container = renderTooltip();
100+
101+
const button = container.querySelector('button');
102+
button?.dispatchEvent(new MouseEvent('mouseenter', {buttons: 1}));
103+
104+
await checkForPendingActivity();
105+
assert.isFalse(container.querySelector('devtools-tooltip')?.open);
106+
});
107+
98108
it('should not be activated if un-focused', async () => {
99109
const container = renderTooltip();
100110

@@ -171,7 +181,7 @@ describe('Tooltip', () => {
171181
});
172182

173183
it('should print a warning if rich tooltip is used with wrong aria label on anchor', () => {
174-
const consoleSpy = sinon.spy(console, 'warn');
184+
const consoleSpy = sinon.stub(console, 'warn');
175185
renderTooltip({variant: 'rich'});
176186
sinon.assert.calledOnce(consoleSpy);
177187
});

front_end/ui/components/tooltips/Tooltip.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ export class Tooltip extends HTMLElement {
156156
this.#anchorObserver?.disconnect();
157157
}
158158

159-
showTooltip = (): void => {
159+
showTooltip = (event?: MouseEvent|FocusEvent): void => {
160+
// Don't show the tooltip if the mouse is down.
161+
if (event && 'buttons' in event && event.buttons) {
162+
return;
163+
}
160164
if (this.#timeout) {
161165
window.clearTimeout(this.#timeout);
162166
}

0 commit comments

Comments
 (0)