Skip to content

Commit

Permalink
Prevent click/selection on edit column
Browse files Browse the repository at this point in the history
vaadin/vaadin-grid-pro#84

* Stop click propagation on edit column, add tests

* Prevent click instead of stopping propagation in capture mode
  • Loading branch information
yuriy-fix authored Mar 25, 2019
1 parent 3ea8a64 commit bb20af1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
ready() {
super.ready();

// Prevent click/selection on edit column
this.$.table.addEventListener('click', e => {
const column = this.getEventContext(e).column;
if (this._isEditColumn(column)) {
e.preventDefault();
}
});

// dblclick does not work on iOS Safari
if (this._ios) {
let firstClickTime;
Expand Down
29 changes: 29 additions & 0 deletions packages/vaadin-grid-pro/test/edit-column.html
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,35 @@
expect(grid.hasAttribute('navigating')).to.be.false;
});
});

describe('grid behaviour', () => {
let grid, cell;

beforeEach(() => {
grid = fixture('default');
grid.items = getItems();
flushGrid(grid);
});

it('should not fire active-item-changed on grid edit column', () => {
// Propagation of click should be stopped on edit colunm
const spy = sinon.spy();
grid.addEventListener('active-item-changed', spy);

cell = getContainerCell(grid.$.items, 0, 1);
cell.click();
expect(spy.called).to.be.false;
});

it('should fire active-item-changed on grid column', () => {
const spy = sinon.spy();
grid.addEventListener('active-item-changed', spy);

cell = getContainerCell(grid.$.items, 0, 2);
cell.click();
expect(spy.called).to.be.true;
});
});
});
</script>

Expand Down

0 comments on commit bb20af1

Please sign in to comment.