Skip to content

Commit

Permalink
fix: do not throw on Tab if grid has tabindex (#3838) (#3839)
Browse files Browse the repository at this point in the history
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
vaadin-bot and web-padawan authored May 12, 2022
1 parent febbbf7 commit 32ffd9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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 @@ -617,6 +617,11 @@ export const KeyboardNavigationMixin = (superClass) =>
_onTabKeyDown(e) {
const focusTarget = this._predictFocusStepTarget(e.composedPath()[0], e.shiftKey ? -1 : 1);

// Can be undefined if grid has tabindex
if (!focusTarget) {
return;
}

// Prevent focus-trap logic from intercepting the event.
e.stopPropagation();

Expand Down
10 changes: 10 additions & 0 deletions packages/grid/test/keyboard-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,16 @@ describe('empty grid', () => {
// Expect programmatic focus on focus exit element
expect(grid.shadowRoot.activeElement).to.equal(grid.$.focusexit);
});

it('should not throw on Shift + Tab when grid has tabindex', () => {
grid.setAttribute('tabindex', '0');

grid.focus();

expect(() => {
shiftTab(grid);
}).to.not.throw(Error);
});
});

describe('hierarchical data', () => {
Expand Down

0 comments on commit 32ffd9d

Please sign in to comment.