From d9dbcf16095bd6d8becd487f0129870a27df8a80 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 15 Nov 2026 16:25:32 +0100 Subject: [PATCH] fix(editor): dialog trigger for references, Task 11 review minors --- apps/app/e2e/shell/editor-citations.spec.ts | 30 +++++++++++++++++-- .../editor/findings/FindingCitations.tsx | 6 +--- .../editor/findings/FindingDialog.tsx | 4 --- .../editor/findings/FindingEditForm.tsx | 3 -- .../editor/findings/FindingView.tsx | 9 ++---- .../editor/references/CitationsPanel.tsx | 2 -- .../editor/references/ReferenceTile.tsx | 27 +++++------------ .../app/src/editor/history/useLeaveConfirm.ts | 2 +- apps/app/src/editor/tabs.ts | 2 +- apps/app/tests/unit/editor-findings.test.tsx | 9 ++---- .../unit/editor-references-panel.test.tsx | 12 ++++---- 11 files changed, 47 insertions(+), 59 deletions(-) diff --git a/apps/app/e2e/shell/editor-citations.spec.ts b/apps/app/e2e/shell/editor-citations.spec.ts index 35960ee5..78381e4e 100644 --- a/apps/app/e2e/shell/editor-citations.spec.ts +++ b/apps/app/e2e/shell/editor-citations.spec.ts @@ -141,7 +141,8 @@ test.describe('references dialog, view mode', () => { const { actor, seed } = await open(page) requests.forbid(actor.account.email, actor.account.password) await openCitations(page, dict, 'Constat A') - await expect(trigger(page)).toHaveAttribute('aria-expanded', 'true') + await expect(trigger(page)).toHaveAttribute('aria-haspopup', 'dialog') + await expect(trigger(page)).not.toHaveAttribute('aria-expanded') await expect( citationsDialog(page).getByRole('heading', { level: 2 }), ).toHaveText(dict['editor.references.dialog_title']) @@ -217,6 +218,30 @@ test.describe('references dialog, view mode', () => { await expect(trigger(page)).toBeFocused() }) + test('a family: « Tout afficher » filters the library by it, Back returns to its dialog', async ({ + page, + }) => { + test.setTimeout(150_000) + await open(page) + await openCitations(page, dict, 'Dysfonction A') + await link(page).click() + await expectNoDialog(page) + const root = libraryRoot(page) + await expect( + root.locator('button[aria-controls][id$="-header"]'), + ).toHaveCount(1) + await expect(root.getByRole('button', { name: /Source B/ })).toBeVisible() + await expect(root.getByTestId('editor-references-filter')).toContainText( + 'Dysfonction A', + ) + await page.goBack() + await expect(page.locator('dialog[open]')).toHaveCount(2) + await expect(panel(page)).toContainText('Zone A › Dysfonction A') + await expect( + findingDialog(page).getByRole('heading', { name: 'Dysfonction A' }), + ).toBeVisible() + }) + test('a long list scrolls inside the dialog; « 0 référence » opens the empty one', async ({ page, }) => { @@ -380,7 +405,6 @@ for (const reduced of [false, true]) { await openCitations(page, dict, 'Constat A') await closeCitations(page, dict) await expect(trigger(page)).toBeFocused() - await expect(trigger(page)).toHaveAttribute('aria-expanded', 'false') await showCitations(page) await page.keyboard.press('Escape') await expect(panel(page)).toHaveCount(0) @@ -534,7 +558,7 @@ test.describe('references dialog, read-only at 375 px', () => { // A tile opens by a tap; the finding dialog's controls underneath stay as they were. await tap(heads(page).first()) await expect(heads(page).first()).toHaveAttribute('aria-expanded', 'true') - await expect(trigger(page)).toHaveAttribute('aria-expanded', 'true') + await expect(citationsDialog(page)).toBeVisible() // Its ✕ closes it only; the trigger holds the focus. await tap( citationsDialog(page).getByRole('button', { name: dict['common.close'] }), diff --git a/apps/app/src/components/editor/findings/FindingCitations.tsx b/apps/app/src/components/editor/findings/FindingCitations.tsx index 2d42753b..5c5bce25 100644 --- a/apps/app/src/components/editor/findings/FindingCitations.tsx +++ b/apps/app/src/components/editor/findings/FindingCitations.tsx @@ -7,8 +7,6 @@ import { useT } from '@/i18n/useT' interface CitationsProps { item: FindingItem - /** The references dialog is open over the finding dialog (the trigger reads « expanded »). */ - citationsOpen: boolean /** Opens the references dialog of the family or node. */ onShowReferences: (opener: HTMLElement) => void } @@ -23,7 +21,6 @@ const RING = function CitationsTrigger({ item, count, - citationsOpen, onShowReferences, }: CitationsProps & { count: number }) { const plural = usePlural() @@ -31,8 +28,7 @@ function CitationsTrigger({