Skip to content

Commit c909a4a

Browse files
authored
fix: do not dispatch event on stopedit when editor loading (#8232) (CP: 24.4) (#8246)
* fix: do not dispatch event on stopedit when editor loading (#8232) (CP 24.4) * Trigger Build
1 parent b3d57b7 commit c909a4a

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export const InlineEditingMixin = (superClass) =>
227227
}
228228

229229
/** @private */
230-
_applyEdit({ path, value, index, item }) {
230+
_applyEdit({ path, value, _, item }) {
231231
set(path, value, item);
232232
this.requestContentUpdate();
233233
}
@@ -273,6 +273,7 @@ export const InlineEditingMixin = (superClass) =>
273273
}
274274

275275
/** @private */
276+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
276277
_isEditColumn(column) {
277278
return column && column.localName.toLowerCase() === 'vaadin-grid-pro-edit-column';
278279
}
@@ -405,7 +406,7 @@ export const InlineEditingMixin = (superClass) =>
405406
}
406407
const { cell, column, model } = this.__edited;
407408

408-
if (!shouldCancel) {
409+
if (!shouldCancel && !this.hasAttribute('loading-editor')) {
409410
const editor = column._getEditorComponent(cell);
410411
if (editor) {
411412
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 '@esm-bundle/chai';
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 {
@@ -370,5 +370,40 @@ describe('keyboard navigation', () => {
370370
await sendKeys({ press: 'Escape' });
371371
expect(getContainerCellContent(grid.$.items, 0, 0).textContent).to.equal('0 foo');
372372
});
373+
374+
it('should not fire event when tabbed through cells with slow editor', async () => {
375+
const itemPropertyChangedSpy = sinon.spy();
376+
grid.addEventListener('item-property-changed', itemPropertyChangedSpy);
377+
378+
const column = grid.querySelector('vaadin-grid-pro-edit-column');
379+
380+
// Custom editor with delayed operations
381+
column.editModeRenderer = (root, _, __) => {
382+
if (!root.firstElementChild) {
383+
const input = document.createElement('input');
384+
let actualValue = '';
385+
Object.defineProperty(input, 'value', {
386+
async get() {
387+
await aTimeout(100);
388+
return actualValue;
389+
},
390+
async set(v) {
391+
await aTimeout(100);
392+
actualValue = v;
393+
},
394+
});
395+
root.appendChild(input);
396+
}
397+
};
398+
399+
const firstCell = getContainerCell(grid.$.items, 0, 0);
400+
dblclick(firstCell._content);
401+
402+
await sendKeys({ press: 'Tab' });
403+
await sendKeys({ press: 'Tab' });
404+
await nextFrame();
405+
406+
expect(itemPropertyChangedSpy.called).to.be.false;
407+
});
373408
});
374409
});

0 commit comments

Comments
 (0)