feat(editor): kept-mounted tabs, sections and references panel

Each visited tab, Annotations section and the references panel stay
mounted in a KeptPlace (hidden, nested visibility). Composed canvases
detach while hidden. One JSON.parse per document text. Focus requests
reach only their owning place.

Rewritten assertions (R-24):
- editor-route.test.tsx:127: annotations testid toBeNull -> not.toBeVisible
- editor-sections.test.tsx: place('annotations.drawing') toBeNull -> not.toBeVisible
- editor-journey.spec.ts:311: page-wide getByLabel('Nom (FR)') -> scoped to place 'general'
- editor-tabs-lists.test.tsx: ReferencesPanel `open` prop dropped (the wrapper hides it)
- editor-annotations-tab, editor-focus-request, editor-sections tests: props gain `visited`
No assertion removed.
This commit is contained in:
bchanot committed 2026-11-06 20:50:40 +01:00
1 parent ca184da4d9
commit 6689827a8d
18 files changed
+847 -81

No files matched your search

@@ -4,11 +4,9 @@ import {
AnnounceContext,
FocusConsumedContext,
ownedBy,
type PlaceName,
} from '@/editor/focusRequest'
import { saveFailureMessage } from '@/editor/messages'
import type { EditorMode } from '@/editor/mode'
import type { NavigationState } from '@/editor/navigation'
import { useEditorStore } from '@/editor/state/editorStore'
import { initialTab } from '@/editor/tabs'
import { useEditorNavigation } from '@/editor/useEditorNavigation'
@@ -19,6 +17,7 @@ import CopyIssueNotice from './CopyIssueNotice'
import DraftHeader from './DraftHeader'
import EditorTabBody from './EditorTabBody'
import EditorTabs from './EditorTabs'
import KeptPlace from './KeptPlace'
import ModeNotice from './ModeNotice'
import RecoveryNotice from './RecoveryNotice'
import ReferencesPanel from './references/ReferencesPanel'
@@ -48,11 +47,6 @@ function SaveFailureNotice() {
)
}
/** The `data-place` the shown tab and section name. */
function shownPlace({ tab, section }: NavigationState): PlaceName {
return tab === 'annotations' ? `annotations.${section}` : tab
}
/**
* The draft page once the version is ready: header, notices, tab row, the references
* panel and the shown place. Owns the navigation state, so the first tab is known at
@@ -85,21 +79,24 @@ export default function EditorWorkspace(props: Props) {
<FocusConsumedContext value={nav.consumed}>
<AnnounceContext value={nav.announce}>
{state.referencesMounted && (
<ReferencesPanel
readOnly={readOnly}
focus={ownedBy(state.focus, 'references')}
open={state.references.open}
onClose={nav.closeReferences}
/>
<KeptPlace name="references" visible={state.references.open}>
<ReferencesPanel
readOnly={readOnly}
focus={ownedBy(state.focus, 'references')}
onClose={nav.closeReferences}
/>
</KeptPlace>
)}
<EditorTabBody
tab={state.tab}
visited={state.visitedTabs}
readOnly={readOnly}
navigate={nav.navigate}
focus={ownedBy(state.focus, shownPlace(state))}
focus={state.focus}
reloadSheet={reloadSheet}
annotations={{
section: state.section,
visited: state.visitedSections,
onOpenSection: nav.openSection,
onBack: nav.backToDrawing,
}}