Skip to content

Commit 9d6acbf

Browse files
CopilotJudahGabriel
andcommitted
Fix keyboard accessibility for back button in portals dialog
Co-authored-by: JudahGabriel <312936+JudahGabriel@users.noreply.github.com>
1 parent 7092b2f commit 9d6acbf

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

apps/pwabuilder/src/script/components/publish-pane.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ export class PublishPane extends LitElement {
334334
#pp-form-header > button:hover {
335335
cursor: pointer;
336336
}
337+
#pp-form-header > button:focus {
338+
outline: 2px solid #000000;
339+
outline-offset: 2px;
340+
border-radius: 4px;
341+
}
337342
#pp-form-header-content {
338343
display: flex;
339344
gap: 1em;
@@ -1145,7 +1150,7 @@ export class PublishPane extends LitElement {
11451150
:
11461151
html`
11471152
<div id="pp-form-header">
1148-
<button type="button"><img src="/assets/new/back_for_package_form.svg" alt="back to store cards button" @click=${() => this.backToCards()} /></button>
1153+
<button type="button" @click=${() => this.backToCards()}><img src="/assets/new/back_for_package_form.svg" alt="back to store cards button" /></button>
11491154
<div id="pp-form-header-content">
11501155
<img src="${this.storeMap[this.selectedStore].logo}" alt="${this.selectedStore} logo" />
11511156
<div id="pp-form-header-text">
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe('Portals Dialog Accessibility', () => {
4+
test.beforeEach(async ({ page }) => {
5+
// Navigate to portals page with test site
6+
await page.goto('/portals?site=https://webboard.app');
7+
});
8+
9+
test('back button should be keyboard accessible', async ({ page }) => {
10+
// Wait for the publish pane to be available
11+
await page.waitForSelector('publish-pane');
12+
13+
// Open the dialog by clicking Generate Package button
14+
const generateButton = page.locator('button:has-text("Generate Package")').first();
15+
await generateButton.click();
16+
17+
// Wait for dialog to open and form to show
18+
await page.waitForSelector('#pp-form-header', { state: 'visible' });
19+
20+
// Find the back button in the form header
21+
const backButton = page.locator('#pp-form-header > button').first();
22+
23+
// Verify button is visible and accessible
24+
await expect(backButton).toBeVisible();
25+
26+
// Test keyboard navigation - tab to the button
27+
await backButton.focus();
28+
29+
// Verify button has focus
30+
await expect(backButton).toBeFocused();
31+
32+
// Test that pressing Enter activates the button
33+
await backButton.press('Enter');
34+
35+
// Verify that we're back to the cards view (form header should not be visible)
36+
await expect(page.locator('#pp-form-header')).not.toBeVisible();
37+
await expect(page.locator('#store-cards')).toBeVisible();
38+
});
39+
40+
test('back button should have proper focus styling', async ({ page }) => {
41+
// Navigate to portals page
42+
await page.goto('/portals?site=https://webboard.app');
43+
44+
// Wait for the publish pane
45+
await page.waitForSelector('publish-pane');
46+
47+
// Open dialog
48+
const generateButton = page.locator('button:has-text("Generate Package")').first();
49+
await generateButton.click();
50+
51+
// Wait for form to show
52+
await page.waitForSelector('#pp-form-header', { state: 'visible' });
53+
54+
// Focus the back button
55+
const backButton = page.locator('#pp-form-header > button').first();
56+
await backButton.focus();
57+
58+
// Check that focus styles are applied
59+
const outlineStyle = await backButton.evaluate((el) => {
60+
return window.getComputedStyle(el).outline;
61+
});
62+
63+
// Verify that the button has an outline when focused
64+
expect(outlineStyle).toContain('solid');
65+
});
66+
});

0 commit comments

Comments
 (0)