diff --git a/apps/app/e2e/shell/editor-annotations.spec.ts b/apps/app/e2e/shell/editor-annotations.spec.ts index 3f6d6952..785bdb7d 100644 --- a/apps/app/e2e/shell/editor-annotations.spec.ts +++ b/apps/app/e2e/shell/editor-annotations.spec.ts @@ -443,6 +443,32 @@ test.describe('editor annotations (A3)', () => { await button(page, 'editor.annotations.trace_close').click() await expect(creationDialog(page, 'zone')).toBeVisible() }) + // « Reprendre le tracé » (board 04 C): the dialog hides, the strip offers its way + // back; nothing moves, the commands fit, then « Revenir aux propriétés ». + await expectNoShift(page, async () => { + await creationDialog(page, 'zone') + .getByRole('button', { + name: dict['editor.annotations.creation.resume'], + }) + .click() + await expect(creationDialog(page, 'zone')).toHaveCount(0) + }) + const strip = page.getByTestId('edit-strip') + await expect(strip).toContainText( + dict['editor.annotations.strip.resumed'], + ) + const fence = (await strip.boundingBox())! + const last = (await strip + .getByRole('button', { + name: dict['editor.annotations.creation.discard'], + }) + .boundingBox())! + expect(last.x + last.width).toBeLessThanOrEqual(fence.x + fence.width) + await expectAccessible(page, `a resumed tracing at ${width} px`) + await expectNoShift(page, async () => { + await button(page, 'editor.annotations.back_to_properties').click() + await expect(creationDialog(page, 'zone')).toBeVisible() + }) }) } diff --git a/apps/app/src/components/editor/annotations/CreationDialog.tsx b/apps/app/src/components/editor/annotations/CreationDialog.tsx index 82cc8f91..99988f5a 100644 --- a/apps/app/src/components/editor/annotations/CreationDialog.tsx +++ b/apps/app/src/components/editor/annotations/CreationDialog.tsx @@ -56,8 +56,7 @@ const NONE: Outcome = { missing: [], messages: [] } * undo); a point lets the core's verdict offer C (C26); a success ends the creation. */ function useCreate(work: Creation, created: { current: boolean }) { - const t = useT() - const locale = useLocaleStore((s) => s.locale) + const context = { t: useT(), locale: useLocaleStore((s) => s.locale) } const [outcome, setOutcome] = useState(NONE) const settle = (attempt: Attempt) => { if (attempt.status === 'invalid') { @@ -74,44 +73,43 @@ function useCreate(work: Creation, created: { current: boolean }) { if (attempt.id) finishCreation(attempt.id, work.pending.kind) else dropCreation() } - const input = { ...work, context: { t, locale } } return { outcome, - create: () => settle(createAttempt(input, work.form)), + create: () => settle(createAttempt({ ...work, context }, work.form)), confirm: () => { const { correction } = work.pending - if (correction) settle(confirmAttempt(input, work.form, correction)) + if (!correction) return + settle(confirmAttempt({ ...work, context }, work.form, correction)) }, } } /** « Point placé · Replacer le point », « Zone tracée, 5 sommets · Reprendre le tracé ». */ -function ShapeLine({ work, readOnly }: { work: Creation; readOnly: boolean }) { +const GLYPH = { point: 'point', zone: 'zone', detail_trigger: 'link' } as const + +/** « Point placé », « Zone tracée, 5 sommets », « Accès tracé, 3 sommets ». */ +function useShapeText(pending: Creation['pending']): string { const t = useT() const locale = useLocaleStore((s) => s.locale) - const { kind, geometry } = work.pending - const count = geometry.type === 'polygon' ? geometry.points.length : 0 - const text = - kind === 'point' - ? t('editor.annotations.creation.placed') - : t( - pluralKey( - locale, - `editor.annotations.creation.traced.${kind}`, - count, - ), - ).replace('{count}', String(count)) - const point = kind === 'point' + const { kind, geometry } = pending + if (geometry.type !== 'polygon') + return t('editor.annotations.creation.placed') + const count = geometry.points.length + const key = `editor.annotations.creation.traced.${kind}` + return t(pluralKey(locale, key, count)).replace('{count}', String(count)) +} + +function ShapeLine({ work, readOnly }: { work: Creation; readOnly: boolean }) { + const t = useT() + const text = useShapeText(work.pending) + const point = work.pending.kind === 'point' return (
- + {text}