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:
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}
|
||||
|
||||
@@ -24,6 +24,12 @@ export function focusRowOrDrawing(id: string): boolean {
|
||||
return focusRow({ kind: 'annotation', id }) || focusDrawing()
|
||||
}
|
||||
|
||||
/** The focused element left with the selection (a handle, the slider): the row takes it. */
|
||||
function focusIfLost(id: string): void {
|
||||
const active = document.activeElement
|
||||
if (active === null || active === document.body) focusRowOrDrawing(id)
|
||||
}
|
||||
|
||||
/** After a tap on the drawing: the box takes the focus, unless it already holds it. */
|
||||
function drawingFocus(): void {
|
||||
if (visibleElement(CANVAS_BOX) !== document.activeElement) focusDrawing()
|
||||
@@ -31,9 +37,9 @@ function drawingFocus(): void {
|
||||
|
||||
/**
|
||||
* Deselecting: `id` is the RESOLVED selection (never the raw id, which can name a removed
|
||||
* annotation). The button always moves the focus to the row; Escape does only when it was
|
||||
* pressed inside the properties panel, whose focused element is about to leave the page.
|
||||
* Anywhere else the focus stays where it is. Both answer whether something was deselected.
|
||||
* annotation). The button always moves the focus to the row; Escape does when it was
|
||||
* pressed inside the properties panel, or when the focused element left with the selection
|
||||
* (the handle, the slider, « Déplacer le point »). Anywhere else the focus stays where it is. Both answer whether something was deselected.
|
||||
*/
|
||||
export function useDeselect(id: string | null, clear: () => void) {
|
||||
const t = useT()
|
||||
@@ -50,7 +56,8 @@ export function useDeselect(id: string | null, clear: () => void) {
|
||||
}
|
||||
return {
|
||||
byButton: () => run(focusRowOrDrawing),
|
||||
byKey: (fromPanel: boolean) => run(fromPanel ? focusRowOrDrawing : null),
|
||||
byKey: (fromPanel: boolean) =>
|
||||
run(fromPanel ? focusRowOrDrawing : focusIfLost),
|
||||
byDrawing: () => run(drawingFocus),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,12 @@ import { useEditorStore } from '../state/editorStore'
|
||||
import { moveStep, type Frame } from './frame'
|
||||
import type { GeometryChange } from './usePlacement'
|
||||
import { takeMove, takePreview, stepSelection } from './previewCommit'
|
||||
import { endMode, startMove, useAnnotationWork } from './workStore'
|
||||
import {
|
||||
endMode,
|
||||
startMove,
|
||||
useAnnotationWork,
|
||||
type Preview,
|
||||
} from './workStore'
|
||||
|
||||
type Drop = (id: string, geometry: Geometry, change?: GeometryChange) => void
|
||||
|
||||
@@ -40,15 +45,26 @@ function step(input: PointEditInput, direction: Direction, big: boolean) {
|
||||
stepSelection(target.id, target.geometry, { x: x * size, y: y * size })
|
||||
}
|
||||
|
||||
/** The commits of the pending work: each takes its preview, fresh only (R-13). */
|
||||
function commits(onDrop: Drop) {
|
||||
/** A preview back on the stored shape (there and back, a pinned slider) is no change. */
|
||||
function changed(
|
||||
preview: Preview | null,
|
||||
target: Annotation | null,
|
||||
): preview is Preview {
|
||||
if (!preview || preview.annotationId !== target?.id) return false
|
||||
return JSON.stringify(preview.geometry) !== JSON.stringify(target.geometry)
|
||||
}
|
||||
|
||||
/** The commits of the pending work: each takes its preview, fresh and changed only (R-13). */
|
||||
function commits({ onDrop, target }: PointEditInput) {
|
||||
const keys = () => {
|
||||
const preview = takePreview('keys')
|
||||
if (preview) onDrop(preview.annotationId, preview.geometry)
|
||||
if (changed(preview, target)) onDrop(preview.annotationId, preview.geometry)
|
||||
}
|
||||
const size = () => {
|
||||
const preview = takePreview('size')
|
||||
if (preview) onDrop(preview.annotationId, preview.geometry, 'size')
|
||||
if (changed(preview, target)) {
|
||||
onDrop(preview.annotationId, preview.geometry, 'size')
|
||||
}
|
||||
}
|
||||
const move = () => {
|
||||
const preview = takeMove()
|
||||
@@ -80,7 +96,7 @@ function handleKeys(input: PointEditInput, commit: ReturnType<typeof commits>) {
|
||||
* « Valider la position » committing once, « Annuler »).
|
||||
*/
|
||||
export function usePointEdit(input: PointEditInput) {
|
||||
const commit = commits(input.onDrop)
|
||||
const commit = commits(input)
|
||||
return {
|
||||
onHandleKey: handleKeys(input, commit),
|
||||
// BDR-050: leaving the handle commits its series; a move mode waits for « Valider ».
|
||||
|
||||
@@ -1672,7 +1672,7 @@ export const en: Dict = {
|
||||
'editor.annotations.move.right': 'Move right',
|
||||
'editor.annotations.move.confirm': 'Confirm position',
|
||||
'editor.annotations.move.cancel': 'Cancel',
|
||||
'editor.annotations.handle.point': 'Point {name}',
|
||||
'editor.annotations.handle.shape': '{kind} {name}',
|
||||
'editor.annotations.guard.move': 'Discard the move?',
|
||||
'editor.annotations.guard.redraw': 'Discard the new tracing?',
|
||||
'editor.annotations.guard.creation': 'Discard the creation?',
|
||||
|
||||
@@ -1702,7 +1702,7 @@ export const fr: Dict = {
|
||||
'editor.annotations.move.right': 'Déplacer vers la droite',
|
||||
'editor.annotations.move.confirm': 'Valider la position',
|
||||
'editor.annotations.move.cancel': 'Annuler',
|
||||
'editor.annotations.handle.point': 'Point {name}',
|
||||
'editor.annotations.handle.shape': '{kind} {name}',
|
||||
'editor.annotations.guard.move': 'Abandonner le déplacement ?',
|
||||
'editor.annotations.guard.redraw': 'Abandonner le nouveau tracé ?',
|
||||
'editor.annotations.guard.creation': 'Abandonner la création ?',
|
||||
|
||||
Reference in new issue
Block a user