-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stop propagation for grid Tab keydown (#3480)
- Loading branch information
1 parent
d0b447f
commit d040976
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { fixtureSync, oneEvent } from '@vaadin/testing-helpers'; | ||
import { sendKeys } from '@web/test-runner-commands'; | ||
import '@vaadin/button'; | ||
import '@vaadin/vaadin-overlay'; | ||
import '../vaadin-grid.js'; | ||
import { flushGrid } from './helpers.js'; | ||
|
||
describe('overlay focus-trap', () => { | ||
let overlay, grid, button; | ||
|
||
function getFirstHeaderCell() { | ||
return grid.$.header.children[0].children[0]; | ||
} | ||
|
||
beforeEach(async () => { | ||
overlay = fixtureSync(`<vaadin-overlay focus-trap></vaadin-overlay>`); | ||
overlay.renderer = (root) => { | ||
if (root.firstChild) { | ||
return; | ||
} | ||
|
||
root.innerHTML = ` | ||
<vaadin-grid style="width: 200px"> | ||
<vaadin-grid-column path="name"></vaadin-grid-column> | ||
</vaadin-grid> | ||
<vaadin-button>Button</vaadin-button> | ||
`; | ||
|
||
grid = root.firstElementChild; | ||
grid.items = [{ name: 'foo' }, { name: 'bar' }]; | ||
flushGrid(grid); | ||
|
||
button = root.lastElementChild; | ||
}; | ||
overlay.opened = true; | ||
await oneEvent(overlay, 'vaadin-overlay-open'); | ||
}); | ||
|
||
it('should correctly move focus on Tab when inside overlay', async () => { | ||
const headerCell = getFirstHeaderCell(); | ||
headerCell.focus(); | ||
|
||
// Move focus to grid body | ||
await sendKeys({ press: 'Tab' }); | ||
|
||
// Move focus to the button | ||
await sendKeys({ press: 'Tab' }); | ||
|
||
expect(document.activeElement).to.equal(button); | ||
}); | ||
}); |