fix(editor): C1 review round 1, note endings tested, tile hook, pin guard

Tests: note ends on another tile's Modifier, on Ajouter une reference, and is
replaced (announced again) by a newer drop; long titles shortened.
Read-only toggle deletes the key from openKeys explicitly. Drop slot and tile
wrappers moved to useTileActions. pinEdited pins nothing for an absent key.
This commit is contained in:
bchanot committed 2026-11-13 11:25:50 +01:00
1 parent 3303530717
commit 1e19479853
4 files changed
+80 -13

No files matched your search

@@ -243,6 +243,26 @@ function useDroppedDrafts(editing: boolean, readOnly: boolean) {
return [dropped, setDropped] as const
}
/** The tile's own actions: « Terminer » refocuses the header, a toggle ends the note. */
function useTileActions(
props: TileProps,
headerRef: RefObject<HTMLButtonElement | null>,
) {
const { on, editing, readOnly } = props
const [dropped, setDropped] = useDroppedDrafts(editing, readOnly)
return {
dropped,
setDropped,
done: () => {
if (on.done()) headerRef.current?.focus()
},
toggle: () => {
setDropped(null)
on.toggle()
},
}
}
/** « Saisie non appliquée : … »: plain text, the live region says it once elsewhere. */
function DroppedNote({ fields }: { fields: readonly Field[] }) {
const droppedText = useDroppedText()
@@ -264,14 +284,7 @@ export default function ReferenceTile(props: TileProps) {
const t = useT()
const base = tileBase(host, position, reference)
const headerRef = useRef<HTMLButtonElement>(null)
const [dropped, setDropped] = useDroppedDrafts(editing, props.readOnly)
const done = () => {
if (on.done()) headerRef.current?.focus()
}
const toggle = () => {
setDropped(null)
on.toggle()
}
const { dropped, setDropped, done, toggle } = useTileActions(props, headerRef)
return (
<li
data-reference-tile