diff --git a/apps/app/e2e/shell/editor-references.spec.ts b/apps/app/e2e/shell/editor-references.spec.ts index 4934fd7e..86ce870a 100644 --- a/apps/app/e2e/shell/editor-references.spec.ts +++ b/apps/app/e2e/shell/editor-references.spec.ts @@ -168,15 +168,24 @@ test.describe('reference tiles, edit mode', () => { const url = tile.getByLabel(dict['editor.reference.url']) await url.fill('exemple.org') await tile - .getByRole('button', { name: dict['editor.references.done'] }) + .getByRole('button', { + name: dict['editor.references.done'], + exact: true, + }) .click() await expect(url).toBeFocused() await expect( - tile.getByRole('button', { name: dict['editor.references.done'] }), + tile.getByRole('button', { + name: dict['editor.references.done'], + exact: true, + }), ).toBeVisible() await url.fill('https://exemple.org/page') await tile - .getByRole('button', { name: dict['editor.references.done'] }) + .getByRole('button', { + name: dict['editor.references.done'], + exact: true, + }) .click() await expect(tile.getByLabel(dict['editor.reference.url'])).toHaveCount(0) await expect( @@ -338,9 +347,8 @@ test.describe('reference tiles, search, sort and add', () => { // No result, then the notice's own clear button. await bar.search.fill('radiographie') - const notice = libraryRoot(page).getByRole('status').filter({ - hasText: 'radiographie', - }) + const notice = libraryRoot(page).getByTestId('editor-references-no-result') + await expect(notice).toContainText('radiographie') await expect(notice).toContainText('Aucune référence ne contient') await expectAccessible(page, 'the no result notice') await notice diff --git a/apps/app/src/components/editor/EditorTabs.tsx b/apps/app/src/components/editor/EditorTabs.tsx index fb6ec0c5..84840fd1 100644 --- a/apps/app/src/components/editor/EditorTabs.tsx +++ b/apps/app/src/components/editor/EditorTabs.tsx @@ -40,10 +40,13 @@ function ErrorCount({ tab }: { tab: EditorTabId }) { ) } +/** Answers false when the change was refused (a field of the open panel refused to apply). */ +type SelectTab = (tab: EditorTabId) => boolean | void + interface TabListProps { shown: readonly EditorTabId[] active: EditorTabId - onSelect: (tab: EditorTabId) => void + onSelect: SelectTab } /** The tablist proper: the shown tabs only, arrows move between them. */ @@ -56,7 +59,7 @@ function TabList({ shown, active, onSelect }: TabListProps) { if (step === 0 || at < 0) return event.preventDefault() const next = shown[(at + step + shown.length) % shown.length] - onSelect(next) + if (onSelect(next) === false) return document.getElementById(tabDomId(next))?.focus() } return ( @@ -89,7 +92,7 @@ function TabList({ shown, active, onSelect }: TabListProps) { interface MoreTabsProps { more: readonly EditorTabId[] active: EditorTabId - onSelect: (tab: EditorTabId) => void + onSelect: SelectTab } /** @@ -164,7 +167,7 @@ function MoreTabs({ more, active, onSelect }: MoreTabsProps) { interface EditorTabsProps { active: EditorTabId tier: TabTier - onSelect: (tab: EditorTabId) => void + onSelect: SelectTab } /** diff --git a/apps/app/src/components/editor/references/CitationsPanel.tsx b/apps/app/src/components/editor/references/CitationsPanel.tsx index f3837832..ac36c732 100644 --- a/apps/app/src/components/editor/references/CitationsPanel.tsx +++ b/apps/app/src/components/editor/references/CitationsPanel.tsx @@ -168,6 +168,7 @@ function EntryTile({ done: tiles.finish, goTo: (target) => navigate(targetOfKey(target)), registerLeave: tiles.registerLeave, + takeFocus: () => tiles.takeFocus(key), }} /> ) @@ -176,7 +177,11 @@ function EntryTile({ /** The cited references as tiles, the dangling ids as rows. */ function Entries({ panel, props }: { panel: Panel; props: Props }) { return ( -