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

+1 -1
View File
@@ -97,7 +97,7 @@ export function focusRow(key: ElementKey): boolean {
return true
}
/** Row-based places (Général, Vues, Catégories, Régions, Références): focus the named row. */
/** Row-based places (Général, Vues, Catégories, Régions): focus the named row. */
export function useRowFocus(focus: FocusRequest | undefined): void {
useFocusRequest(focus, (target) =>
target.key && focusRow(target.key) ? 'found' : 'none',
+17 -11
View File
@@ -62,14 +62,15 @@ export interface EditorNavigation {
/** The polite live region's text; a repeat alternates a trailing no-break space. */
live: string
navigate: (target: EditorTarget) => void
selectTab: (tab: EditorTabId) => void
/** False when the open panel refused the tab change (a refused field keeps the page). */
selectTab: (tab: EditorTabId) => boolean
openSection: (section: AnnotationSection, opener?: Opener) => void
backToDrawing: () => void
/** Opens the citations panel of a finding node; any other key is ignored. */
openCitations: (citedBy: ElementKey, opener?: Opener) => void
/** A user close (✕, Escape, scrim): the panel exits, then the focus goes to P6's fallbacks. */
closeCitations: () => void
/** The finding vanished: the same close, never refused (a refused draft is dropped, said aloud). */
/** The finding vanished: the same close, never refused (a refused draft is dropped, said). */
dropCitations: () => void
/** « Tout afficher dans l'onglet Références »: panel closed, tab shown, library reset. */
showAllReferences: () => void
@@ -199,20 +200,24 @@ interface PanelContext {
/**
* Records a close of the panel. A user close asks the panel first (P22''): a refused
* draft cancels it. While an exit is playing, a close is a no-op (a tab choice replaces
* the pending move) and asks nothing: the draft was settled by the first close.
* draft cancels it (false). While an exit is playing, a close is a no-op (a tab choice
* replaces the pending move) and asks nothing: the draft was settled by the first close.
*/
function useRequestClose(ctx: PanelContext) {
const { open, exit, canLeave } = ctx
const { busy, record } = exit
return useCallback(
(move: PendingClose, forced: boolean) => {
if (!open) return
if (busy()) return record(move)
(move: PendingClose, forced: boolean): boolean => {
if (!open) return true
if (busy()) {
record(move)
return true
}
commitFocusedField()
const { allowed, note } = canLeave.current?.(forced) ?? { allowed: true }
if (!allowed) return
if (!allowed) return false
record(note ? { ...move, note } : move)
return true
},
[open, busy, record, canLeave],
)
@@ -228,14 +233,14 @@ function useOpenCitations(ctx: PanelContext) {
commitFocusedField()
openers.citations.current = opener ?? null
openers.citedBy.current = citedBy
announce(t('editor.place.references'))
announce(t('editor.references.panel_title'))
dispatch({ type: 'open_citations', citedBy })
},
[openers, dispatch, announce, t],
)
}
/** The closes of the panel: ✕ / Escape / scrim, the vanished finding, « Tout afficher », « Aller à ». */
/** The panel's closes: ✕ / Escape / scrim, the vanished finding, « Tout afficher », « Aller à ». */
function useCloseMoves(ctx: PanelContext) {
const t = useT()
const moveText = useMoveText()
@@ -373,7 +378,7 @@ function useTabSelect(
) {
const t = useT()
return useCallback(
(tab: EditorTabId) => {
(tab: EditorTabId): boolean => {
const action = { type: 'select_tab', tab } as const
if (open) {
const text = t(`editor.tab.${tab}`)
@@ -381,6 +386,7 @@ function useTabSelect(
}
commitFocusedField()
dispatch(action)
return true
},
[request, dispatch, open, t],
)