fix(web): focus trap inside portal (#11797)
* fix(web): focus trap inside portal * fix tests
This commit is contained in:
@@ -6,19 +6,22 @@ import { tick } from 'svelte';
|
||||
describe('focusTrap action', () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
it('sets focus to the first focusable element', () => {
|
||||
it('sets focus to the first focusable element', async () => {
|
||||
render(FocusTrapTest, { show: true });
|
||||
await tick();
|
||||
expect(document.activeElement).toEqual(screen.getByTestId('one'));
|
||||
});
|
||||
|
||||
it('supports backward focus wrapping', async () => {
|
||||
render(FocusTrapTest, { show: true });
|
||||
await tick();
|
||||
await user.keyboard('{Shift>}{Tab}{/Shift}');
|
||||
expect(document.activeElement).toEqual(screen.getByTestId('three'));
|
||||
});
|
||||
|
||||
it('supports forward focus wrapping', async () => {
|
||||
render(FocusTrapTest, { show: true });
|
||||
await tick();
|
||||
screen.getByTestId('three').focus();
|
||||
await user.keyboard('{Tab}');
|
||||
expect(document.activeElement).toEqual(screen.getByTestId('one'));
|
||||
@@ -28,9 +31,7 @@ describe('focusTrap action', () => {
|
||||
render(FocusTrapTest, { show: false });
|
||||
const openButton = screen.getByText('Open');
|
||||
|
||||
openButton.focus();
|
||||
openButton.click();
|
||||
await tick();
|
||||
await user.click(openButton);
|
||||
expect(document.activeElement).toEqual(screen.getByTestId('one'));
|
||||
|
||||
screen.getByText('Close').click();
|
||||
|
||||
Reference in New Issue
Block a user