Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ export const KeyboardNavigationMixin = (superClass) =>
}
// Inform cell content of the focus (used in <vaadin-grid-sorter>)
cell._content.dispatchEvent(new CustomEvent('cell-focusin', { bubbles: false }));

// Fire a public event for cell focus.
cell.dispatchEvent(new CustomEvent('cell-focus', { bubbles: true, composed: true }));
}

this._detectFocusedItemIndex(e);
Expand Down
30 changes: 30 additions & 0 deletions packages/vaadin-grid/test/keyboard-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,36 @@ describe('keyboard navigation', () => {

expect(spy.callCount).to.equal(1);
});

it('should dispatch cell-focus on keyboard navigation', (done) => {
const expectedContext = {
column: grid.querySelector('vaadin-grid-column'),
detailsOpened: false,
expanded: false,
index: 0,
item: 'foo',
level: 0,
section: 'body',
selected: false
};

tabToBody();
right();

const spy = sinon.spy();

grid.addEventListener('cell-focus', (e) => {
spy();

const context = e.target.getEventContext(e);
expect(context).to.deep.equal(expectedContext);
done();
});

left();

expect(spy.calledOnce).to.be.true;
});
});
});

Expand Down