feat(editor): sheet landings, history and e2e for the finding layers

« Tout afficher » clears the search and keeps the sort. A landing waits
for the dialogs a move closed and for their focus restore. Helpers and
shell specs move to the dialog and sheet flow; new finding dialog spec
(entries, guards, flip, gone rule, Back and Forward over the layers).
This commit is contained in:
bchanot committed 2026-11-13 19:03:21 +01:00
1 parent 18085cecf8
commit 4731a3376a
21 files changed
+782 -474

No files matched your search

@@ -1,5 +1,5 @@
import { useEffect, useRef, type KeyboardEvent } from 'react'
import { afterModalsClosed } from '@/components/ui/afterModalsClosed'
import { landAfterModalsClosed } from '@/components/ui/afterModalsClosed'
import StatusBadge from '@/components/editor/findings/StatusBadge'
import { keyMove, type FindingItem } from '@/editor/findings/tree'
import { useT } from '@/i18n/useT'
@@ -38,7 +38,7 @@ export default function FindingTree(props: FindingTreeProps) {
useEffect(() => {
if (!focusId) return
// After the dialogs a move closed: the page behind them is inert until then.
afterModalsClosed(() => refs.current.get(focusId.id)?.focus())
landAfterModalsClosed(() => refs.current.get(focusId.id)?.focus())
onFocused()
}, [focusId, onFocused])
const current = visible.find((item) => item.id === selectedId) ?? visible[0]
@@ -27,7 +27,8 @@ interface Shown {
/**
* The search, the sort and the resulting tile order of the Références tab. All three are
* display state: nothing here reaches the document (BDR-114). `resetSignal` (« Tout
* afficher ») empties the search and the sort once per bump; the tab stays mounted (A2).
* afficher ») empties the search once per bump and keeps the sort (R2F-4); the tab stays
* mounted (A2).
* The tile that entered edit is pinned at the index it was shown at, whatever the search
* or the sort, and stays pinned after « Terminer » until the next search or sort change,
* so the tile the user just edited never vanishes under their focus (P23, I1). A
@@ -50,7 +51,7 @@ export function useReferenceView(
: { key, index: keys.indexOf(key) }
if (seen !== resetSignal) {
setSeen(resetSignal)
setView(INITIAL)
setView({ ...view, query: '' })
setPinned(pinEdited(editingKey))
}
const pinAt = pinned === null ? -1 : keys.indexOf(pinned.key)
@@ -28,3 +28,12 @@ export function flushAfterModals(): void {
waiting.clear()
ready.forEach((fn) => fn())
}
/**
* `afterModalsClosed` for a focus landing: a dialog closed in the same commit restores
* its own focus in a microtask queued before this call, so the landing waits one more
* microtask and is never undone by it.
*/
export function landAfterModalsClosed(fn: () => void): () => void {
return afterModalsClosed(() => queueMicrotask(fn))
}