Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reset stored column order on mousedown #3527

Merged
merged 2 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions packages/grid/src/vaadin-grid-keyboard-navigation-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export const KeyboardNavigationMixin = (superClass) =>
this.addEventListener('mousedown', () => {
this.toggleAttribute('navigating', false);
this._isMousedown = true;

if (this._focusedColumnOrder !== undefined) {
tomivirkki marked this conversation as resolved.
Show resolved Hide resolved
// Reset stored order when moving focus with mouse.
this._focusedColumnOrder = undefined;
}
});
this.addEventListener('mouseup', () => (this._isMousedown = false));
}
Expand Down
18 changes: 18 additions & 0 deletions packages/grid/test/keyboard-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,24 @@ describe('keyboard navigation', () => {
});
});

describe('mixing keyboard and mouse', () => {
it('should update column after mousedown on other cell', () => {
// Focus cell in third column
focusWithMouse(getRowCell(0, 2));

down();

expect(getFocusedCellIndex()).to.equal(2);

// Focus cell in first column
focusWithMouse(getRowCell(0, 0));

down();

expect(getFocusedCellIndex()).to.equal(0);
});
});

describe('with hidden columns', () => {
it('should skip over hidden column with right arrow', () => {
grid._columnTree[0][1].hidden = true;
Expand Down