fix(bugs): obs card click + next-RDV radio + PDF toBlob fallback + head svg interactivity

Five fixes from manual QA:

1. ObservationCard — clicking anywhere on the card now selects it.
   The wrapping button only covered the text rows; empty space was dead.
   The whole card is now role="button" with keyboard (Enter/Space) support;
   inner action buttons (↑ ↓ 🗑) stop propagation so they don't double-fire.
   This was also the root cause of "details look stuck" — the active
   observation simply wasn't being switched.

2. NextAppointmentPicker — when value === undefined the "Date" radio was
   still showing as checked because `kind` defaulted to 'date'. The three
   radios now read from the raw `value?.kind` (which can be undefined),
   so "Aucun" is the only checked option when no next RDV is set.

3. svgToPng.rasterizeSvg — `canvas.toBlob` can return null in some
   browsers when the canvas state is unusual; the call now falls back to
   `canvas.toDataURL('image/png')` and decodes the base64 payload. Also
   paints a white background before canvg renders (so the PDF embed is
   opaque) and clamps width/height to >= 1px to avoid zero-area canvases.
   canvg errors are caught + logged instead of propagating, so the export
   still produces a (possibly blank) page rather than throwing.

4. svgConvention.parseSvgBones — clickable bones are now distinguished
   from decorative ones. Interactive = has a hitbox element OR category
   is spine-zone OR head. Decorative bones (teeth, malar, mandible,
   nasal-bone, facial-crest, individual vertebrae paths…) get
   `pointer-events: none` applied to their elements and are excluded from
   the returned map. Result: in Horse_head.svg, frontal/temporal/parietal/
   sphenoid/occipital/atm/ssb/c0-c1/hyoid become clickable as intended,
   while teeth / malar / mandible no longer intercept the clicks.

5. (covered by #1) — the per-observation details panel always read the
   active observation; the bug was the click handler scope. Confirmed by
   switching observations: the editor section now updates immediately.

88 tests still pass, lint clean, build clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude Opus 4.7 committed 2026-05-18 22:48:13 +02:00
1 parent 9a99fc916b
commit bdf5e6475b
5 files changed
+189 -37

No files matched your search

+72 -16
View File
@@ -30,39 +30,95 @@ export default function ObservationCard({
const patCount =
observation.pathologyIds.length + observation.freeTextPathologies.length
function onCardKey(event: React.KeyboardEvent<HTMLDivElement>) {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
onSelect()
}
}
function stop(fn: () => void) {
return (event: React.MouseEvent) => {
event.stopPropagation()
fn()
}
}
return (
<Card
className={[
'cursor-pointer p-4 transition',
active ? 'ring-2 ring-[var(--color-accent)]' : 'hover:bg-[var(--color-surface-strong)]',
active
? 'ring-2 ring-[var(--color-accent)]'
: 'hover:bg-[var(--color-surface-strong)]',
].join(' ')}
>
<div className="flex items-start justify-between gap-3">
<button
type="button"
onClick={onSelect}
className="flex-1 text-left"
aria-label={`Sélectionner l'observation ${index + 1}`}
>
<div
role="button"
tabIndex={0}
aria-label={`Sélectionner l'observation ${index + 1}`}
aria-pressed={active}
onClick={onSelect}
onKeyDown={onCardKey}
className="flex items-start justify-between gap-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]/40 rounded-lg"
>
<div className="flex-1 min-h-[60px] text-left">
<div className="flex items-center gap-2 mb-2">
<Badge tone="neutral">Observation #{index + 1}</Badge>
{observation.severity && (
<Badge tone={observation.severity === 'sévère' ? 'danger' : observation.severity === 'modérée' ? 'warn' : 'neutral'}>
<Badge
tone={
observation.severity === 'sévère'
? 'danger'
: observation.severity === 'modérée'
? 'warn'
: 'neutral'
}
>
{observation.severity}
</Badge>
)}
</div>
<div className="text-sm text-[var(--color-ink-muted)]">
{zoneCount} zone{zoneCount > 1 ? 's' : ''} · {patCount} pathologie{patCount > 1 ? 's' : ''}
{zoneCount} zone{zoneCount > 1 ? 's' : ''} · {patCount} pathologie
{patCount > 1 ? 's' : ''}
</div>
{observation.comment && (
<p className="mt-2 text-sm line-clamp-2 text-[var(--color-ink)]">{observation.comment}</p>
<p className="mt-2 text-sm line-clamp-2 text-[var(--color-ink)]">
{observation.comment}
</p>
)}
</button>
<div className="flex flex-col gap-1">
<Button size="sm" variant="ghost" disabled={!canMoveUp} onClick={onMoveUp} aria-label="Monter">↑</Button>
<Button size="sm" variant="ghost" disabled={!canMoveDown} onClick={onMoveDown} aria-label="Descendre">↓</Button>
<Button size="sm" variant="ghost" onClick={onDelete} aria-label="Supprimer">🗑</Button>
</div>
<div
className="flex flex-col gap-1"
onClick={(event) => event.stopPropagation()}
>
<Button
size="sm"
variant="ghost"
disabled={!canMoveUp}
onClick={stop(onMoveUp)}
aria-label="Monter"
>
↑
</Button>
<Button
size="sm"
variant="ghost"
disabled={!canMoveDown}
onClick={stop(onMoveDown)}
aria-label="Descendre"
>
↓
</Button>
<Button
size="sm"
variant="ghost"
onClick={stop(onDelete)}
aria-label="Supprimer"
>
🗑
</Button>
</div>
</div>
</Card>