fix(editor): never drop a refused draft silently on a read-only flip

Drop slot is tile-local state; the edit view cleanup reports every pending
field (FIELDS order) only when some are pending. The tile shows a warning
note and says it once in the live region; it ends on toggle, Terminer or a
newer drop. LeaveGuard returns all refused fields (forced panel close names
them all). Pin follows editingKey through read-only; reset re-pins it.
Read-only toggle ends edit and collapses. Flip focus goes to the tile header.

R-24 mapping:
- view test "keeps its index ... read-only (M3)": renamed, same assertion
- view test "is suspended in read-only ...": rewritten as "stays pinned in
  read-only" (pin kept, tile still shown after a search); toggle test added
- reset test extended: tile in edit stays pinned through the reset
- new editor-references-flip.test.tsx covers (a)-(g); (h) is a stated limit
This commit is contained in:
bchanot committed 2026-11-13 11:11:51 +01:00
1 parent 52aac41472
commit 3303530717
15 files changed
+543 -94

No files matched your search

@@ -356,7 +356,7 @@ describe('the tile in edit is pinned (P23)', () => {
expect(document.activeElement).toBe(header('r1'))
})
it('keeps its index across a search or sort change made while read-only (M3)', async () => {
it('keeps the tile in edit at its index across a sort change made while read-only (M3)', async () => {
const { user, view } = await mount()
await user.selectOptions(sortBox(), 'citation')
await startEdit(user, 'r3')
@@ -367,15 +367,32 @@ describe('the tile in edit is pinned (P23)', () => {
expect(order()).toEqual(['r2', 'r3', 'r1', 'r5', 'r4'])
})
it('is suspended in read-only: the tile renders its read view', async () => {
it('stays pinned in read-only: the read view of the tile, still shown after a search', async () => {
const { user, view } = await mount()
await startEdit(user, 'r1')
await user.selectOptions(sortBox(), 'citation')
view.rerender(lib(true))
expect(screen.queryByLabelText('Citation')).toBeNull()
expect(order()).toEqual(['r5', 'r3', 'r4', 'r2', 'r1'])
expect(order()).toEqual(['r1', 'r5', 'r3', 'r4', 'r2'])
await user.type(search(), 'alpha')
expect(order()).toEqual(['r5'])
expect(order()).toEqual(['r1', 'r5'])
view.rerender(lib(false))
expect(order()).toEqual(['r1', 'r5'])
expect(
within(header('r1').closest('li')!).getByLabelText('Citation'),
).toBeVisible()
})
it('a read-only toggle ends the edit state and collapses the tile', async () => {
const { user, view } = await mount()
await startEdit(user, 'r1')
view.rerender(lib(true))
expect(header('r1')).toHaveAttribute('aria-expanded', 'true')
await user.click(header('r1'))
expect(header('r1')).toHaveAttribute('aria-expanded', 'false')
view.rerender(lib(false))
expect(header('r1')).toHaveAttribute('aria-expanded', 'false')
expect(screen.queryByLabelText('Citation')).toBeNull()
})
})
@@ -494,6 +511,9 @@ describe('the reset path (« Tout afficher »)', () => {
expect(order()).toHaveLength(5)
expect(header('r2')).toHaveAttribute('aria-expanded', 'true')
expect(within(item).getByLabelText('Citation')).toBeInTheDocument()
// The tile in edit stays pinned through the reset: a new search does not hide it.
await user.type(search(), 'alpha')
expect(order()).toEqual(['r1', 'r5'])
})
})