diff --git a/.travis.yml b/.travis.yml index d144054..f9d95c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ sudo: false dist: xenial language: node_js -node_js: 8.11 +node_js: 10.23 cache: directories: diff --git a/demo/grid-pro-edit-column-demos.html b/demo/grid-pro-edit-column-demos.html index ee103fd..756e7cd 100644 --- a/demo/grid-pro-edit-column-demos.html +++ b/demo/grid-pro-edit-column-demos.html @@ -128,6 +128,29 @@
+ When editOnClick
is set on the grid element, cell edit mode gets activated on a single click
+ instead of the default double click.
+
When enterNextRow
is set on the grid element, the following keys change behavior:
diff --git a/src/vaadin-grid-pro-inline-editing-mixin.html b/src/vaadin-grid-pro-inline-editing-mixin.html
index 9912b5c..e57c9da 100644
--- a/src/vaadin-grid-pro-inline-editing-mixin.html
+++ b/src/vaadin-grid-pro-inline-editing-mixin.html
@@ -47,6 +47,14 @@
notify: true // FIXME(yuriy-fix): needed by Flow counterpart
},
+ /**
+ * When true, the grid enters cell edit mode on a single click
+ * instead of the default double click.
+ */
+ editOnClick: {
+ type: Boolean,
+ },
+
/** @private */
_editingDisabled: {
type: Boolean
@@ -104,6 +112,9 @@
const column = this.getEventContext(e).column;
if (column && this._isEditColumn(column)) {
e.preventDefault();
+ if (this.editOnClick) {
+ this._enterEditFromEvent(e);
+ }
}
});
@@ -131,7 +142,9 @@
});
} else {
this.addEventListener('dblclick', e => {
- this._enterEditFromEvent(e);
+ if (!this.editOnClick) {
+ this._enterEditFromEvent(e);
+ }
});
}
}
diff --git a/test/edit-column-renderer.html b/test/edit-column-renderer.html
index 1176d1d..1e63713 100644
--- a/test/edit-column-renderer.html
+++ b/test/edit-column-renderer.html
@@ -165,6 +165,23 @@
const secondCell = getContainerCell(grid.$.items, 0, 2);
expect(secondCell._content.textContent).to.equal('new');
});
+
+ describe('single click edit', () => {
+
+ beforeEach(() => grid.editOnClick = true);
+
+ it('should enter edit mode on single click', () => {
+ firstCell._content.dispatchEvent(new CustomEvent('click', {bubbles: true, composed: true}));
+ expect(getCellEditor(firstCell)).to.be.ok;
+ });
+
+ it('should not enter edit mode on single click', () => {
+ grid.editOnClick = false;
+ firstCell._content.dispatchEvent(new CustomEvent('click', {bubbles: true, composed: true}));
+ expect(getCellEditor(firstCell)).not.to.be.ok;
+ });
+
+ });
});
describe('custom edit mode renderer', () => {