Skip to content

Commit ea24ab2

Browse files
authored
fix: do not dispatch event on stopedit when editor loading (#8232)
1 parent e42d3af commit ea24ab2

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

packages/grid-pro/src/vaadin-grid-pro-inline-editing-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export const InlineEditingMixin = (superClass) =>
401401
}
402402
const { cell, column, model } = this.__edited;
403403

404-
if (!shouldCancel) {
404+
if (!shouldCancel && !this.hasAttribute('loading-editor')) {
405405
const editor = column._getEditorComponent(cell);
406406
if (editor) {
407407
const value = column._getEditorValue(editor);

packages/grid-pro/test/keyboard-navigation.common.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@vaadin/chai-plugins';
2-
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers';
2+
import { aTimeout, fixtureSync, nextFrame } from '@vaadin/testing-helpers';
33
import { sendKeys } from '@web/test-runner-commands';
44
import sinon from 'sinon';
55
import {
@@ -352,5 +352,40 @@ describe('keyboard navigation', () => {
352352
await sendKeys({ press: 'Escape' });
353353
expect(getContainerCellContent(grid.$.items, 0, 0).textContent).to.equal('0 foo');
354354
});
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+
});
355390
});
356391
});

0 commit comments

Comments
 (0)