|
1 | 1 | import { expect } from '@vaadin/chai-plugins';
|
2 |
| -import { fixtureSync, nextFrame } from '@vaadin/testing-helpers'; |
| 2 | +import { aTimeout, fixtureSync, nextFrame } from '@vaadin/testing-helpers'; |
3 | 3 | import { sendKeys } from '@web/test-runner-commands';
|
4 | 4 | import sinon from 'sinon';
|
5 | 5 | import {
|
@@ -352,5 +352,40 @@ describe('keyboard navigation', () => {
|
352 | 352 | await sendKeys({ press: 'Escape' });
|
353 | 353 | expect(getContainerCellContent(grid.$.items, 0, 0).textContent).to.equal('0 foo');
|
354 | 354 | });
|
| 355 | + |
| 356 | + it('should not fire event when tabbed through cells with slow editor', async () => { |
| 357 | + const itemPropertyChangedSpy = sinon.spy(); |
| 358 | + grid.addEventListener('item-property-changed', itemPropertyChangedSpy); |
| 359 | + |
| 360 | + const column = grid.querySelector('vaadin-grid-pro-edit-column'); |
| 361 | + |
| 362 | + // Custom editor with delayed operations |
| 363 | + column.editModeRenderer = (root, _, __) => { |
| 364 | + if (!root.firstElementChild) { |
| 365 | + const input = document.createElement('input'); |
| 366 | + let actualValue = ''; |
| 367 | + Object.defineProperty(input, 'value', { |
| 368 | + async get() { |
| 369 | + await aTimeout(100); |
| 370 | + return actualValue; |
| 371 | + }, |
| 372 | + async set(v) { |
| 373 | + await aTimeout(100); |
| 374 | + actualValue = v; |
| 375 | + }, |
| 376 | + }); |
| 377 | + root.appendChild(input); |
| 378 | + } |
| 379 | + }; |
| 380 | + |
| 381 | + const firstCell = getContainerCell(grid.$.items, 0, 0); |
| 382 | + dblclick(firstCell._content); |
| 383 | + |
| 384 | + await sendKeys({ press: 'Tab' }); |
| 385 | + await sendKeys({ press: 'Tab' }); |
| 386 | + await nextFrame(); |
| 387 | + |
| 388 | + expect(itemPropertyChangedSpy.called).to.be.false; |
| 389 | + }); |
355 | 390 | });
|
356 | 391 | });
|
0 commit comments