Skip to content

Commit

Permalink
fix: do not dispatch event on stopedit when editor loading (#8232) (C…
Browse files Browse the repository at this point in the history
…P: 24.4) (#8246)

* fix: do not dispatch event on stopedit when editor loading (#8232) (CP 24.4)

* Trigger Build
  • Loading branch information
ugur-vaadin authored Dec 2, 2024
1 parent b3d57b7 commit c909a4a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/grid-pro/src/vaadin-grid-pro-inline-editing-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export const InlineEditingMixin = (superClass) =>
}

/** @private */
_applyEdit({ path, value, index, item }) {
_applyEdit({ path, value, _, item }) {
set(path, value, item);
this.requestContentUpdate();
}
Expand Down Expand Up @@ -273,6 +273,7 @@ export const InlineEditingMixin = (superClass) =>
}

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

if (!shouldCancel) {
if (!shouldCancel && !this.hasAttribute('loading-editor')) {
const editor = column._getEditorComponent(cell);
if (editor) {
const value = column._getEditorValue(editor);
Expand Down
37 changes: 36 additions & 1 deletion packages/grid-pro/test/keyboard-navigation.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@esm-bundle/chai';
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers';
import { aTimeout, fixtureSync, nextFrame } from '@vaadin/testing-helpers';
import { sendKeys } from '@web/test-runner-commands';
import sinon from 'sinon';
import {
Expand Down Expand Up @@ -370,5 +370,40 @@ describe('keyboard navigation', () => {
await sendKeys({ press: 'Escape' });
expect(getContainerCellContent(grid.$.items, 0, 0).textContent).to.equal('0 foo');
});

it('should not fire event when tabbed through cells with slow editor', async () => {
const itemPropertyChangedSpy = sinon.spy();
grid.addEventListener('item-property-changed', itemPropertyChangedSpy);

const column = grid.querySelector('vaadin-grid-pro-edit-column');

// Custom editor with delayed operations
column.editModeRenderer = (root, _, __) => {
if (!root.firstElementChild) {
const input = document.createElement('input');
let actualValue = '';
Object.defineProperty(input, 'value', {
async get() {
await aTimeout(100);
return actualValue;
},
async set(v) {
await aTimeout(100);
actualValue = v;
},
});
root.appendChild(input);
}
};

const firstCell = getContainerCell(grid.$.items, 0, 0);
dblclick(firstCell._content);

await sendKeys({ press: 'Tab' });
await sendKeys({ press: 'Tab' });
await nextFrame();

expect(itemPropertyChangedSpy.called).to.be.false;
});
});
});

0 comments on commit c909a4a

Please sign in to comment.