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

+17 -4
View File
@@ -162,16 +162,29 @@ export function heldElement(): HTMLElement | null {
: null
}
/** The disclosure button of the reference tile that holds `element`, if any. */
export function tileHeaderOf(element: HTMLElement | null): HTMLElement | null {
const tile = element?.closest('[data-reference-tile]')
return tile?.querySelector<HTMLElement>('[data-tile-header]') ?? null
}
/**
* After the render that hides parts: `held` (taken before) that left the page or sits in a
* hidden part hands its focus to the shown tab; one still shown gets its focus back when
* the commit blurred it (never `body`), and the tab takes it if the element refuses.
* hidden part hands its focus to `home` (the header of the tile it was in) when that is
* still shown, else to the shown tab; one still shown gets its focus back when the commit
* blurred it (never `body`), and the tab takes it if the element refuses.
*/
export function refocusIfHidden(held: HTMLElement | null): void {
export function refocusIfHidden(
held: HTMLElement | null,
home: HTMLElement | null = null,
): void {
if (!held) return
const gone = !held.isConnected || held.closest('[hidden]')
if (!gone && document.activeElement !== held) held.focus()
if (gone || document.activeElement !== held) focusActiveTab()
if (!gone && document.activeElement === held) return
const homeShown = home?.isConnected && !home.closest('[hidden]')
if (homeShown) home.focus()
if (!homeShown || document.activeElement !== home) focusActiveTab()
}
/**