From 8240f21fea841bcb18b76eea70e00760bcdb19d2 Mon Sep 17 00:00:00 2001 From: Exelo Date: Mon, 23 Nov 2026 09:21:43 +0100 Subject: [PATCH 1/9] fix(console): expose the problems as a tree of files and problems Each file of the Problems panel was a section listitem holding its expand button and its problem buttons: the list announced the files only, and the problems were no items (WCAG 1.3.1). The panel is now a flat tree: a file is a level 1 treeitem with aria-expanded, its problems level 2 treeitems, which matches its arrow keys (Left and Right fold). The empty state sits outside the tree. Closes #324 --- apps/editor/e2e/console.spec.ts | 38 ++++++++------- apps/editor/e2e/ecs.spec.ts | 7 ++- .../src/widgets/problems/ProblemsView.svelte | 48 +++++++++++-------- 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/apps/editor/e2e/console.spec.ts b/apps/editor/e2e/console.spec.ts index 59c6af7f..bbff292c 100644 --- a/apps/editor/e2e/console.spec.ts +++ b/apps/editor/e2e/console.spec.ts @@ -119,20 +119,26 @@ test('problems: a file that is not open, grouped by file, opens at its position' 'true', ); - const file = page - .getByRole('list', { name: 'Problems' }) - .getByRole('listitem', { name: 'scratch/broken.ts' }); - const problem = file.getByRole('button', { name: /is not assignable to type 'number'/ }); + /** A tree: files at level 1 fold, their problems are the level 2 items. */ + const tree = page.getByRole('tree', { name: 'Problems' }); + const file = tree.getByRole('treeitem', { name: /scratch\/broken\.ts/, level: 1 }); + const problem = tree.getByRole('treeitem', { + name: /is not assignable to type 'number'/, + level: 2, + }); await expect(problem).toContainText('typescript 2322'); await expect(problem).toContainText('2:14'); - await expect(file.getByRole('button', { name: /scratch\/broken\.ts/ })).toContainText('1 error'); + await expect(file).toContainText('1 error'); + await expect(file).toHaveAttribute('aria-expanded', 'true'); - await file.getByRole('button', { name: /scratch\/broken\.ts/ }).click(); + await file.click(); + await expect(file).toHaveAttribute('aria-expanded', 'false'); await expect(problem).toHaveCount(0); - await file.getByRole('button', { name: /scratch\/broken\.ts/ }).click(); + await file.click(); await page.getByLabel('Search problems').fill("assignable to type 'number'"); - await expect(page.getByRole('list', { name: 'Problems' }).getByRole('listitem')).toHaveCount(1); + await expect(tree.getByRole('treeitem', { level: 1 })).toHaveCount(1); + await expect(tree.getByRole('treeitem', { level: 2 })).toHaveCount(1); await page .getByRole('group', { name: 'Severities' }) .getByRole('button', { name: 'Errors' }) @@ -145,13 +151,12 @@ test('problems: a file that is not open, grouped by file, opens at its position' await page.getByLabel('Search problems').fill(''); /** One Tab stop: arrows go through files and problems, Enter opens one. */ - const header = file.getByRole('button', { name: /scratch\/broken\.ts/ }); - await header.focus(); + await file.focus(); await page.keyboard.press('ArrowRight'); await expect(problem).toBeFocused(); - await expect(header).toHaveAttribute('tabindex', '-1'); + await expect(file).toHaveAttribute('tabindex', '-1'); await page.keyboard.press('ArrowLeft'); - await expect(header).toBeFocused(); + await expect(file).toBeFocused(); await page.keyboard.press('ArrowLeft'); await expect(problem).toHaveCount(0); await page.keyboard.press('ArrowRight'); @@ -181,11 +186,12 @@ test.describe('with the engine', () => { await open(page, 'game'); await showPanel(page, 'Problems'); writeFileSync(MAIN, `${original}const = ;\n`); - const file = page - .getByRole('list', { name: 'Problems' }) - .getByRole('listitem', { name: 'apps/client/src/main.ts' }); - const build = file.getByRole('button').filter({ hasText: /\bbuild\b/ }); + const tree = page.getByRole('tree', { name: 'Problems' }); + const build = tree.getByRole('treeitem', { level: 2 }).filter({ hasText: /\bbuild\b/ }); await expect(build.first()).toBeVisible({ timeout: 30_000 }); + await expect( + tree.getByRole('treeitem', { name: /apps\/client\/src\/main\.ts/, level: 1 }), + ).toBeVisible(); await expect(build.first()).toContainText(new RegExp(`${errorLine}:\\d+$`)); await showPanel(page, 'Console'); await expect( diff --git a/apps/editor/e2e/ecs.spec.ts b/apps/editor/e2e/ecs.spec.ts index d200c94d..67198310 100644 --- a/apps/editor/e2e/ecs.spec.ts +++ b/apps/editor/e2e/ecs.spec.ts @@ -361,10 +361,9 @@ test('a layout warning of a component shows in Problems, at its declaration', as ); try { await showPanel(page, 'Problems'); - const file = page - .getByRole('list', { name: 'Problems' }) - .getByRole('listitem', { name: 'apps/client/src/components/components.ts' }); - const warning = file.getByRole('button', { name: /Position: The preset "vector" needs/ }); + const warning = page + .getByRole('tree', { name: 'Problems' }) + .getByRole('treeitem', { name: /Position: The preset "vector" needs/, level: 2 }); await expect(warning).toBeVisible({ timeout: 15_000 }); await warning.click(); await expect(page.locator('.monaco-editor .active-line-number')).toHaveText( diff --git a/plugins/console/src/widgets/problems/ProblemsView.svelte b/plugins/console/src/widgets/problems/ProblemsView.svelte index 0992c29d..1f7321c9 100644 --- a/plugins/console/src/widgets/problems/ProblemsView.svelte +++ b/plugins/console/src/widgets/problems/ProblemsView.svelte @@ -136,25 +136,28 @@ - -
{ - const row = (event.target as HTMLElement).closest('[data-row]')?.dataset.row; - if (row) active = row; - }} - > - {#each groups as group (group.key)} - {@const open_ = !collapsed.includes(group.key)} -
+ {#if groups.length} + +
{ + const row = (event.target as HTMLElement).closest('[data-row]')?.dataset.row; + if (row) active = row; + }} + > + {#each groups as group (group.key)} + {@const open_ = !collapsed.includes(group.key)}
- {:else} + {/each} +
+ {:else} +
- {/each} -
+ + {/if}