feat(editor): finding dialog and citations side sheet in the history

Constats opens each element in one modal dialog (view, edit with a
local draft, creation) driven by the editor view layer of the browser
history. The citations panel becomes a modal side sheet stacked over
it; its geometry, exit machinery and page inertness are removed.
Back and Forward restore the layers, a dirty form asks first.
This commit is contained in:
bchanot committed 2026-11-13 18:51:35 +01:00
1 parent 8e4f02620a
commit 18085cecf8
50 files changed
+2642 -1504

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { act, screen, waitFor, within } from '@testing-library/react'
import type userEvent from '@testing-library/user-event'
type User = ReturnType<typeof userEvent.setup>
export const treeRow = (name: RegExp) => screen.getByRole('treeitem', { name })
/** The open finding dialog: the layer dialog that is not the citations sheet. */
export const findingDialog = () =>
[...document.querySelectorAll<HTMLElement>('dialog[open][data-layer]')].find(
(dialog) => !dialog.querySelector('[data-testid="editor-citations-panel"]'),
) ?? null
/** Expands a tree row from the keyboard: a click would open its dialog (R2F-3). */
export async function expandRow(user: User, name: RegExp) {
act(() => treeRow(name).focus())
await user.keyboard('{ArrowRight}')
}
/**
* Activates the row of `name` (a click): its dialog opens. The family is expanded first
* when the row is hidden under it.
*/
export async function openFinding(
user: User,
name: RegExp,
family: RegExp = /Cat A/,
) {
if (!screen.queryByRole('treeitem', { name })) await expandRow(user, family)
await user.click(treeRow(name))
await waitFor(() => expect(findingDialog()).not.toBeNull())
}
/** The dialog's content, queried like a place. */
export const inFindingDialog = () => within(findingDialog()!)
+38
View File
@@ -0,0 +1,38 @@
import { vi } from 'vitest'
import CitationsSheet from '@/components/editor/references/CitationsSheet'
import FindingsTab from '@/components/editor/tabs/FindingsTab'
import { findingLayerOf } from '@/editor/findingLayer'
import { citationsOfView } from '@/editor/navigation'
import { useEditorNavigation } from '@/editor/useEditorNavigation'
import { ReadOnlyContext } from '@/editor/editingContext'
/**
* Constats with the navigation that drives its dialog and the sheet over it (what the
* workspace gives it), without the rest of the editor.
*/
export default function FindingsHost({
readOnly = false,
}: {
readOnly?: boolean
}) {
const nav = useEditorNavigation('findings')
return (
<ReadOnlyContext value={readOnly}>
<FindingsTab
readOnly={readOnly}
navigate={vi.fn()}
reloadSheet={vi.fn()}
layer={findingLayerOf(nav)}
/>
<CitationsSheet
citedBy={citationsOfView(nav.state)}
readOnly={readOnly}
guards={nav.guards}
onClose={nav.closeCitations}
onShowAll={nav.showAllReferences}
navigate={nav.navigate}
returnFocus={nav.citationsTrigger}
/>
</ReadOnlyContext>
)
}