-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
68 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@itwin/itwinui-react': patch | ||
--- | ||
|
||
Adjusted focus management in `Popover` so that it allows interactive elements inside the popover to be more easily focused. This more closely matches the behavior of the HTML `<dialog>` element, which focuses the first interactive element inside it. |
Binary file modified
BIN
+1.45 KB
(100%)
...t-workshop/cypress-visual-screenshots/baseline/ColorPicker.test.ts-Advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+244 Bytes
(100%)
...workshop/cypress-visual-screenshots/baseline/ColorPicker.test.ts-With Alpha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.21 KB
(100%)
...t-workshop/cypress-visual-screenshots/baseline/Table.test.ts-Column Manager.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.54 KB
(90%)
...react-workshop/cypress-visual-screenshots/baseline/TimePicker.test.ts-Basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,31 @@ | ||
import { Popover } from '@itwin/itwinui-react'; | ||
import { useSearchParams } from '@remix-run/react'; | ||
|
||
export default function Page() { | ||
const [searchParams] = useSearchParams(); | ||
|
||
const shouldImperativeFocus = searchParams.get('imperativeFocus') === 'true'; | ||
const shouldFocusInput = searchParams.get('focusInput') === 'true'; | ||
|
||
return ( | ||
<> | ||
<Popover | ||
applyBackground | ||
content={ | ||
<div> | ||
<h2 | ||
tabIndex={-1} | ||
ref={shouldImperativeFocus ? (el) => el?.focus() : undefined} | ||
> | ||
Popover title | ||
</h2> | ||
<p>Popover content</p> | ||
{shouldFocusInput && <input />} | ||
</div> | ||
} | ||
> | ||
<button>Open</button> | ||
</Popover> | ||
</> | ||
); | ||
} |
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,31 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Popover (focus)', () => { | ||
test('should focus the popover by default', async ({ page }) => { | ||
await page.goto('/Popover'); | ||
await page.click('button'); | ||
await expect(page.getByRole('dialog')).toBeFocused(); | ||
}); | ||
|
||
test('should allow imperative focus', async ({ page }) => { | ||
await page.goto('/Popover?imperativeFocus=true'); | ||
await page.click('button'); | ||
await expect(page.getByRole('heading')).toBeFocused(); | ||
}); | ||
|
||
test('should prioritize interactive elements inside the popover content (over the popover element)', async ({ | ||
page, | ||
}) => { | ||
await page.goto('/Popover?focusInput=true'); | ||
await page.click('button'); | ||
await expect(page.locator('input')).toBeFocused(); | ||
}); | ||
|
||
test('should prioritize imperative focus over interactive elements', async ({ | ||
page, | ||
}) => { | ||
await page.goto('/Popover?focusInput=true&imperativeFocus=true'); | ||
await page.click('button'); | ||
await expect(page.getByRole('heading')).toBeFocused(); | ||
}); | ||
}); |