fix(editor): one history entry per reference edit, focus kept

Final review fixes. « Terminer » and every panel close re-committed the
edited field against a stale value, adding a second identical history
entry so the first « Défaire » seemed to do nothing: the tile now reads
the latest applied value (tests assert the undo-length delta). A tile
leaving the search on « Terminer » stays pinned until the next view
change and keeps focus; « Ajouter la référence » resets search and sort
and focuses the new tile. Also: refused draft dropped on a read-only
flip is announced; arrow keys respect a refused tab switch; pinned
index kept across read-only; the panel announces « Références citées »;
search text inserted literally; « Aller à » names its citer; the edit
header's name starts with « Terminer. »; undo removing the focused panel
tile moves focus per P20; no-result announced once; docs corrected.

Gates: typecheck, lint, test:run (app 1510), build, e2e:ui 251;
e2e:shell 16 specs (admin and editor-equine excluded): 117 passed / 108
skipped / 1 failed (crossing:211 stuck on the MFA step-up screen before
the editor), rerun alone 11 passed; full-row guard: no pre-existing row
changed in any table.
This commit is contained in:
bchanot committed 2026-11-13 01:08:00 +01:00
1 parent 2182307c62
commit 1bf27014b3
21 files changed
+677 -136

No files matched your search

@@ -9,7 +9,7 @@ import CitersList from './CitersList'
import ReferenceEditor from './ReferenceEditor'
import ReferenceFacts from './ReferenceFacts'
import type { ReferenceHost } from './referenceTypes'
import type { LeaveGuard } from './useReferenceEdit'
import { useDropNote, type Field, type LeaveGuard } from './useReferenceEdit'
/** What a tile asks of the library that owns its state. */
export interface TileHandlers {
@@ -23,6 +23,8 @@ export interface TileHandlers {
move?: (position: number) => void
goTo: (key: ElementKey) => void
registerLeave: (guard: LeaveGuard | null) => void
/** True once after « Modifier »: the edit view then focuses its Citation field. */
takeFocus: () => boolean
}
/** What a tile of the citations panel adds: the finding it belongs to and « Retirer ». */
@@ -97,7 +99,15 @@ function TileHeader({
<span
className={`min-w-0 break-words text-sm ${open || editing ? '' : 'line-clamp-2'} ${editing ? 'font-semibold' : ''}`}
>
{editing ? t('editor.references.edit_title') : reference.citation}
{editing ? (
// In edit this button ends the edit: its name says so, the title stays visible (M7).
<>
<span className="sr-only">{t('editor.references.done')}. </span>
{t('editor.references.edit_title')}
</>
) : (
reference.citation
)}
</span>
<span className="col-start-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-[var(--color-ink-muted)] sm:col-start-3 sm:row-start-1 sm:flex-col sm:items-end">
{!editing && (
@@ -216,6 +226,8 @@ export default function ReferenceTile(props: TileProps) {
const t = useT()
const base = tileBase(host, position, reference)
const headerRef = useRef<HTMLButtonElement>(null)
const dropped = useRef<Field | null>(null)
useDropNote(props.readOnly, dropped)
const done = () => {
if (on.done()) headerRef.current?.focus()
}
@@ -231,7 +243,11 @@ export default function ReferenceTile(props: TileProps) {
<ReferenceEditor
reference={reference}
base={base}
registerLeave={on.registerLeave}
hooks={{
registerLeave: on.registerLeave,
takeFocus: on.takeFocus,
dropped,
}}
/>
) : (
<ReferenceFacts reference={reference} />