Skip to content

Commit e479d73

Browse files
fix: hide and don't show tooltip while scrolling the grid (#4819) (#4822)
Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
1 parent d5f96ac commit e479d73

4 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎integration/tests/grid-tooltip.test.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
aTimeout,
55
enter,
66
escKeyDown,
7+
fire,
78
fixtureSync,
89
focusin,
910
focusout,
@@ -12,6 +13,7 @@ import {
1213
nextRender,
1314
tabKeyDown,
1415
} from '@vaadin/testing-helpers';
16+
import { sendKeys } from '@web/test-runner-commands';
1517
import sinon from 'sinon';
1618
import '@vaadin/grid/vaadin-grid.js';
1719
import '@vaadin/tooltip/vaadin-tooltip.js';
@@ -209,6 +211,39 @@ describe('tooltip', () => {
209211
expect(tooltip.opened).to.be.false;
210212
});
211213

214+
it('should hide the tooltip when starting scrolling', async () => {
215+
const cell = getCell(grid, 0);
216+
mouseenter(cell);
217+
218+
fire(grid.$.table, 'scroll');
219+
await nextFrame();
220+
221+
expect(tooltip.opened).to.be.false;
222+
});
223+
224+
it('should not hide the tooltip when scrolling using keyboard navigation', async () => {
225+
const cell = getCell(grid, 0);
226+
tabKeyDown(document.body);
227+
focusin(cell);
228+
expect(tooltip.opened).to.be.true;
229+
230+
await sendKeys({ press: 'ArrowDown' });
231+
fire(grid.$.table, 'scroll');
232+
await nextFrame();
233+
234+
expect(tooltip.opened).to.be.true;
235+
});
236+
237+
it('should not show the tooltip on mouseenter while scrolling', async () => {
238+
fire(grid.$.table, 'scroll');
239+
await nextFrame();
240+
241+
const cell = getCell(grid, 0);
242+
mouseenter(cell);
243+
244+
expect(tooltip.opened).to.be.false;
245+
});
246+
212247
it('should not set tooltip target if there is no tooltip', async () => {
213248
const spy = sinon.spy(grid._tooltipController, 'setTarget');
214249

‎packages/grid/src/vaadin-grid-scroll-mixin.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ export const ScrollMixin = (superClass) =>
137137
if (!this.hasAttribute('reordering')) {
138138
this._scheduleScrolling();
139139
}
140+
if (!this.hasAttribute('navigating')) {
141+
this._hideTooltip(true);
142+
}
140143

141144
this._updateOverflow();
142145
}

‎packages/grid/src/vaadin-grid.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,9 @@ class Grid extends ElementMixin(
675675
// For now we only support tooltip on desktop
676676
if (!isAndroid && !isIOS) {
677677
cell.addEventListener('mouseenter', (event) => {
678-
this._showTooltip(event);
678+
if (!this.$.scroller.hasAttribute('scrolling')) {
679+
this._showTooltip(event);
680+
}
679681
});
680682

681683
cell.addEventListener('mouseleave', () => {

‎packages/grid/test/helpers.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import sinon from 'sinon';
22

33
export const flushGrid = (grid) => {
44
grid._observer.flush();
5+
grid._afterScroll();
56
if (grid._debounceScrolling) {
67
grid._debounceScrolling.flush();
78
}
8-
grid._afterScroll();
99
if (grid._debounceOverflow) {
1010
grid._debounceOverflow.flush();
1111
}

0 commit comments

Comments
 (0)