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:
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))
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createContext, useContext, useEffect, useRef } from 'react'
|
||||
import type { ElementKey } from '@faunosteo/core-wasm/types'
|
||||
import { afterModalsClosed } from '@/components/ui/afterModalsClosed'
|
||||
import { landAfterModalsClosed } from '@/components/ui/afterModalsClosed'
|
||||
import type {
|
||||
AnnotationSection,
|
||||
EditorTarget,
|
||||
@@ -107,7 +107,7 @@ export function focusRow(key: ElementKey): boolean {
|
||||
*/
|
||||
export function focusRowLater(key: ElementKey): boolean {
|
||||
if (!rowOf(key)) return false
|
||||
afterModalsClosed(() => void focusRow(key))
|
||||
landAfterModalsClosed(() => void focusRow(key))
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useLocation, useNavigate, useNavigationType } from 'react-router-dom'
|
||||
import { afterModalsClosed } from '@/components/ui/afterModalsClosed'
|
||||
import { landAfterModalsClosed } from '@/components/ui/afterModalsClosed'
|
||||
import { focusActiveTab } from '../focusRequest'
|
||||
import { sameView, type EditorView } from '../navigation'
|
||||
import {
|
||||
@@ -248,7 +248,7 @@ function useLanding(
|
||||
if (!landing || landed.current === landing) return
|
||||
landed.current = landing
|
||||
const { id, view } = landing.entry
|
||||
return afterModalsClosed(() => {
|
||||
return landAfterModalsClosed(() => {
|
||||
window.scrollTo(0, book.scrolls.get(id) ?? 0)
|
||||
landFocus(landing)
|
||||
if (landing.layerChanged && !landing.tabChanged) return
|
||||
|
||||
@@ -9,7 +9,10 @@ import {
|
||||
type RefObject,
|
||||
} from 'react'
|
||||
import type { ElementKey } from '@faunosteo/core-wasm/types'
|
||||
import { afterModalsClosed } from '@/components/ui/afterModalsClosed'
|
||||
import {
|
||||
afterModalsClosed,
|
||||
landAfterModalsClosed,
|
||||
} from '@/components/ui/afterModalsClosed'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import {
|
||||
commitFocusedField,
|
||||
@@ -393,7 +396,7 @@ function useMoveFocus(
|
||||
if (outcome === 'found' || outcome === 'kept') return
|
||||
dispatch({ type: 'focus_consumed', serial })
|
||||
}
|
||||
afterModalsClosed(() => {
|
||||
landAfterModalsClosed(() => {
|
||||
if (move.kind === 'back') backTarget(openers.section.current)?.focus()
|
||||
else landingOf(move, state)?.focus()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user