fix(editor): no silent move loss, no empty commit, focus kept

- « Toutes les annotations » in the properties panel asks the drawing
  guard before it drops a started move (R-12); tests also cover a tool
  and « Ajouter un point ».
- A keyboard series back on its place, or a slider pinned at its stop,
  commits nothing.
- Escape that deselects from the handle or the slider moves the focus to
  the row (or the drawing) instead of losing it.
- A link circle keeps its handle, named « Accès {nom} », with no slider
  and no move mode (no label for it in REVUE).
- The move-mode drop notice waits until the body is shown (R-14).
- No layout shift: the strip's lead has a fixed width, the commands and
  the message pill get a new box per set or message.
- Doc: hit shapes use pointer-events auto; the fine « − » bubble is
  board 05's size.
- Tests: R-14 flip, A5 through the Point tool click, the repair e2e
  wrapped in expectNoShift.
This commit is contained in:
bchanot committed 2026-11-17 19:08:08 +01:00
1 parent 91e94952f0
commit 44de465c6d
10 files changed
+240 -35

No files matched your search

@@ -60,7 +60,9 @@ function Lead({ lead }: { lead: StripLead }) {
return (
<div
data-testid="edit-strip-lead"
className="flex min-w-0 max-w-[45%] shrink items-start gap-2"
// A fixed width: a longer or shorter lead (a mode, a tracing) never moves the
// notice beside it (A14).
className="flex w-2/5 min-w-0 shrink-0 items-start gap-2"
>
<span className="mt-0.5 shrink-0 text-[var(--color-ink-muted)]">
<EditorGlyph name={lead.icon} size={16} />
@@ -177,17 +177,21 @@ function useModeFollowsSelection(selectedId: string | null) {
}, [modeId, selectedId])
}
/** R-13: a started mode a change made elsewhere dropped is said on the line. */
/**
* R-13: a started mode a change made elsewhere dropped is said on the line, once the body
* is shown (a drop while read-only is said on the way back).
*/
function useDroppedNotice(message: GestureMessages) {
const t = useT()
const visible = usePlaceVisible()
const dropped = useAnnotationWork((s) => s.dropped)
const show = message.show
useEffect(() => {
if (dropped === null) return
if (dropped === null || !visible) return
useAnnotationWork.setState({ dropped: null })
const text = t(`editor.annotations.dropped.${dropped}`)
show(text, { undo: false, tone: 'info' })
}, [dropped, show, t])
}, [dropped, visible, show, t])
}
export default function EditableAnnotations(props: Props) {
@@ -253,15 +257,19 @@ function CanvasColumn({
)
}
/** The point handle of the movable selected circle, named « Point {nom} ». */
/** The handle of the movable selected circle, named « Point {nom} » (« Accès {nom} »). */
function useHandle(target: Annotation | null, doc: AnatomicalSheetDocument) {
const t = useT()
const locale = useLocaleStore((s) => s.locale)
if (!target?.geometry) return null
const name = annotationName(target, doc.views, locale)
const kind = t(`editor.annotations.kind.${target.kind}`)
const label = t('editor.annotations.handle.shape')
.replace('{kind}', () => kind)
.replace('{name}', () => name)
return {
annotationId: target.id,
label: t('editor.annotations.handle.point').replace('{name}', () => name),
label,
stored: target.geometry,
}
}
@@ -369,7 +377,8 @@ function SidePanel({
dispatch={dispatch}
context={context}
navigate={scene.navigate}
onShowAll={() => dispatch({ type: 'select', id: null })}
// « Tout afficher » leaves the selection: a started move asks first (R-12).
onShowAll={guarded(() => dispatch({ type: 'select', id: null }))}
busy={ui.tracing !== null || moving}
/>
)
@@ -436,7 +445,7 @@ function SceneStrip({ scene, work }: { scene: Scene; work: Work }) {
lead={lead}
notice={notice}
commands={<SceneCommands scene={scene} work={work} />}
commandsKey={commandsKeyOf(ui, moving, work.target !== null)}
commandsKey={commandsKeyOf(ui, moving, work.target?.kind === 'point')}
/>
)
}
@@ -459,7 +468,8 @@ function SceneCommands({ scene, work }: { scene: Scene; work: Work }) {
/>
)
}
if (work.target) {
// A link circle keeps its handle but has no size and no move mode (R-10; no label).
if (work.target?.kind === 'point') {
const props = { doc, viewId, frame, edit: work.edit }
return <SelectionPointCommands annotation={work.target} {...props} />
}
@@ -48,8 +48,11 @@ function Message({ messages }: { messages: GestureMessages }) {
const { message, hold } = messages
if (!message) return null
const error = message.tone === 'error'
const { stamp } = message
return (
<p
// Another message is another pill: a wider one replacing it moves no box (A14).
key={`${message.text}|${stamp.undo}|${stamp.redo}|${stamp.text.length}`}
data-testid="gesture-message"
role={error ? 'alert' : undefined}
{...hold}