From fe333c2bbde47be8f46567cecd37bab11db30b5c Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 17 Nov 2026 23:41:24 +0100 Subject: [PATCH] fix(editor): creation question lapses, guard sites and flip tested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The creation's « Abandonner la création ? » no longer outlives it: « Replacer le point », « Reprendre le tracé », « Créer » (« Utiliser cette position » included) and « Annuler le tracé » clear a question still open, which would otherwise reappear over the page. Locals trimmed in the creation dialog and the tracing actions (5 max). Tests added (no assertion removed): the two lapses (RED without the fix, GREEN with it); a view chip and a tool ask during a tracing; the mode flip keeps the dialog, its form and the ghost; a history jump out of the editor waits for the creation's question; e2e: « Reprendre le tracé » and « Revenir aux propriétés » under expectNoShift at 1 024, 1 180 and 1 280 px, the strip's last command inside it, axe on the resumed state. --- apps/app/e2e/shell/editor-annotations.spec.ts | 26 ++++ .../editor/annotations/CreationDialog.tsx | 50 ++++---- .../src/editor/annotations/creationWork.ts | 19 ++- .../src/editor/annotations/usePlacement.ts | 14 +- .../unit/editor-creation-dialog.test.tsx | 120 +++++++++++++++++- .../tests/unit/editor-leave-cascade.test.tsx | 27 ++++ 6 files changed, 219 insertions(+), 37 deletions(-) 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}