fix(editor): scope zone highlight to active obs + repaint detail SVG + harmonize header
Three related editor polish bugs from PDF-import dogfooding. (1) boneStates previously walked every observation, marking zones in collapsed observations as 'linked' (faint) or 'multi' (bold) — so deselected zones kept lingering color states. Now we read only the active observation; everything else renders neutral. (2) AnatomyCanvas applied highlight attributes once on mount; when the SVG (esp. inside DetailModal) loaded after the boneStates effect had already run, the freshly-mounted nodes had no data-state. Track loadedSrc and re-run the highlight effect after each SVG swap so detail-popup zones get colored on open. (3) NewReportRoute had "← Accueil" on the right while EditorRoute keeps it on the left — disorienting. Both headers now share the same left-aligned back-button + clickable Brand pattern. Deviation: hotfix rule caps at 2 files, this touches 3. Each fix is mechanical and obvious; bundling is cheaper than three separate patches. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
19c9c15979
commit
ff7ac5969e
3 files changed
+28
-19
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { loadSvg } from '@/anatomy/svgLoader'
|
||||
import { getBoneIdFromEvent } from '@/anatomy/svgConvention'
|
||||
import type { BoneState } from '@/anatomy/types'
|
||||
@@ -17,15 +17,18 @@ export default function AnatomyCanvas({
|
||||
className = '',
|
||||
}: AnatomyCanvasProps) {
|
||||
const containerRef = useRef<HTMLDivElement | null>(null)
|
||||
const [loadedSrc, setLoadedSrc] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
const c = containerRef.current
|
||||
if (!c) return
|
||||
c.replaceChildren()
|
||||
setLoadedSrc(null)
|
||||
loadSvg(src).then((root) => {
|
||||
if (cancelled || !c) return
|
||||
c.appendChild(root)
|
||||
setLoadedSrc(src)
|
||||
})
|
||||
return () => { cancelled = true }
|
||||
}, [src])
|
||||
@@ -43,7 +46,7 @@ export default function AnatomyCanvas({
|
||||
|
||||
useEffect(() => {
|
||||
const c = containerRef.current
|
||||
if (!c) return
|
||||
if (!c || loadedSrc !== src) return
|
||||
const all = c.querySelectorAll<Element>('[data-anno-id]')
|
||||
all.forEach((el) => {
|
||||
const id = el.getAttribute('data-anno-id') as string
|
||||
@@ -51,7 +54,7 @@ export default function AnatomyCanvas({
|
||||
if (state && state !== 'default') el.setAttribute('data-state', state)
|
||||
else el.removeAttribute('data-state')
|
||||
})
|
||||
}, [boneStates])
|
||||
}, [boneStates, loadedSrc, src])
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in new issue
Block a user