diff --git a/apps/app/src/components/editor/EditorTabBody.tsx b/apps/app/src/components/editor/EditorTabBody.tsx index a70a2d91..b6935a26 100644 --- a/apps/app/src/components/editor/EditorTabBody.tsx +++ b/apps/app/src/components/editor/EditorTabBody.tsx @@ -42,7 +42,7 @@ interface Props extends EditorPlaceProps { /** A panel takes the focus after « Plus »: the ring shows for the keyboard only. */ const PANEL_FOCUS = - 'focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]' + 'focus:outline-none focus-visible:outline-2 focus-visible:outline-transparent focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]' function TabPanel({ id, diff --git a/apps/app/src/components/editor/EditorWorkspace.tsx b/apps/app/src/components/editor/EditorWorkspace.tsx index 641e6590..77250151 100644 --- a/apps/app/src/components/editor/EditorWorkspace.tsx +++ b/apps/app/src/components/editor/EditorWorkspace.tsx @@ -140,7 +140,10 @@ function useRestoredView(owner: HistoryOwner) { return view } -/** A step that brought a finding back shows Constats, where its row is revealed. */ +/** + * A step that brought a finding back shows Constats, where its row is revealed. The tab + * move is a history entry on purpose: Back returns to where the user was. + */ function useShowRestored(nav: EditorNavigation) { const revealed = useEditorStore((s) => s.revealed) const { tab } = nav.state diff --git a/apps/app/src/components/editor/tabs/FindingsTab.tsx b/apps/app/src/components/editor/tabs/FindingsTab.tsx index 9e87b3f5..420290b7 100644 --- a/apps/app/src/components/editor/tabs/FindingsTab.tsx +++ b/apps/app/src/components/editor/tabs/FindingsTab.tsx @@ -63,8 +63,8 @@ function useFindingDeletion( setAsk({ target, fallback: fallbackAfterRemoval(items, item) }) } // The element is gone: its dialog closes in the same move, by the pop of its entry (a - // Back step that was taken, never a dead one left behind) and the focus lands on the nearest row once every dialog is closed, unless a newer - // landing supersedes it. + // Back step that was taken, never a dead one left behind). The focus lands on the + // nearest row once every dialog is closed, unless a newer landing supersedes it. const closeDelete = () => { setAsk(null) if (!ask || currentItems().some((item) => item.id === selectedId)) return diff --git a/apps/app/src/editor/state/editorEdit.ts b/apps/app/src/editor/state/editorEdit.ts index b6353038..419d14ba 100644 --- a/apps/app/src/editor/state/editorEdit.ts +++ b/apps/app/src/editor/state/editorEdit.ts @@ -83,7 +83,7 @@ export function stepHistory( if (!replaced.ok) return replaced const patch = replacedPatch(state, step.text, replaced.state, step.history) const key = appearedFinding(state.documentText, step.text) - api.set(key ? { ...patch, revealed: { key } } : patch) + api.set({ ...patch, revealed: key ? { key } : null }) return { ok: true } } diff --git a/apps/app/tests/unit/editor-finding-dialog.test.tsx b/apps/app/tests/unit/editor-finding-dialog.test.tsx index f58596a7..3c23cf9f 100644 --- a/apps/app/tests/unit/editor-finding-dialog.test.tsx +++ b/apps/app/tests/unit/editor-finding-dialog.test.tsx @@ -195,6 +195,35 @@ describe('deleting (owner item 3)', () => { await waitFor(() => expect(row).toHaveFocus()) }) + it('a later step that brings no finding back refocuses nothing', async () => { + const user = await mount() + const zone = { kind: 'zone', id: 'zone-a' } + const element = { + kind: 'zone', + value: { + id: 'zone-a', + name: name('Zone B'), + categories: doc().finding_zones[0].categories, + }, + } + act(() => { + store.getState().commit({ op: 'update', key: zone, element } as never) + }) + await openFinding(user, /Node A/) + await deleteOpen(user) + const undo = () => + user.click(screen.getByRole('button', { name: /^Défaire/ })) + await undo() + const row = await screen.findByRole('treeitem', { name: /Node A/ }) + await waitFor(() => expect(row).toHaveFocus()) + expect(store.getState().revealed).toBeNull() + act(() => row.blur()) + await undo() + await screen.findByRole('treeitem', { name: /Zone A/ }) + expect(store.getState().revealed).toBeNull() + expect(row).not.toHaveFocus() + }) + it('« Refaire » of a creation shows its row the same way', async () => { const user = await mount() await openFinding(user, /Node A/)