diff --git a/apps/app/e2e/shell/editor-annotations.spec.ts b/apps/app/e2e/shell/editor-annotations.spec.ts
index 785bdb7d..ffc5866e 100644
--- a/apps/app/e2e/shell/editor-annotations.spec.ts
+++ b/apps/app/e2e/shell/editor-annotations.spec.ts
@@ -469,6 +469,46 @@ test.describe('editor annotations (A3)', () => {
await button(page, 'editor.annotations.back_to_properties').click()
await expect(creationDialog(page, 'zone')).toBeVisible()
})
+ // The zone abandoned (asked inside its dialog), then a point placed and replaced:
+ // « Taille » shows beside « Revenir aux propriétés » (board 02), nothing moves.
+ await creationDialog(page, 'zone')
+ .getByRole('button', {
+ name: dict['editor.annotations.creation.discard'],
+ })
+ .click()
+ await creationDialog(page, 'zone')
+ .getByRole('group', {
+ name: dict['editor.annotations.guard.creation'],
+ })
+ .getByRole('button', {
+ name: dict['editor.annotations.guard.discard'],
+ })
+ .click()
+ await expect(creationDialog(page, 'zone')).toHaveCount(0)
+ await tool(page, 'point').click()
+ await clickDrawing(page, 300, 500)
+ await expect(creationDialog(page, 'point')).toBeVisible()
+ await expect(strip.getByTestId('size-slider')).toHaveCount(0)
+ await expectNoShift(page, async () => {
+ await creationDialog(page, 'point')
+ .getByRole('button', {
+ name: dict['editor.annotations.creation.replace'],
+ })
+ .click()
+ await expect(creationDialog(page, 'point')).toHaveCount(0)
+ await expect(strip.getByTestId('size-slider')).toBeVisible()
+ })
+ const edge = (await strip.boundingBox())!
+ const end = (await strip
+ .getByRole('button', {
+ name: dict['editor.annotations.creation.discard'],
+ })
+ .boundingBox())!
+ expect(end.x + end.width).toBeLessThanOrEqual(edge.x + edge.width)
+ await expectNoShift(page, async () => {
+ await clickDrawing(page, 320, 520)
+ await expect(creationDialog(page, 'point')).toBeVisible()
+ })
})
}
diff --git a/apps/app/src/components/editor/annotations/CreationDialog.tsx b/apps/app/src/components/editor/annotations/CreationDialog.tsx
index 99988f5a..76b214fb 100644
--- a/apps/app/src/components/editor/annotations/CreationDialog.tsx
+++ b/apps/app/src/components/editor/annotations/CreationDialog.tsx
@@ -1,4 +1,4 @@
-import { useRef, useState, type RefObject } from 'react'
+import { useEffect, useRef, useState, type RefObject } from 'react'
import type { AnatomicalSheetDocument } from '@faunosteo/core-wasm/types'
import DiscardConfirm from '@/components/editor/findings/DiscardConfirm'
import ReadOnlyNotice from '@/components/editor/findings/ReadOnlyNotice'
@@ -87,6 +87,17 @@ function useCreate(work: Creation, created: { current: boolean }) {
/** « Point placé · Replacer le point », « Zone tracée, 5 sommets · Reprendre le tracé ». */
const GLYPH = { point: 'point', zone: 'zone', detail_trigger: 'link' } as const
+/** The dialog's first line (board 02, 04): the shape, then « Replacer » or « Reprendre ». */
+const LINE =
+ 'flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg ' +
+ 'bg-[var(--color-surface-strong)] px-3 py-2 text-sm outline-none'
+
+/** Its link-styled button: the strong accent passes axe's contrast on that background. */
+const LINK =
+ 'min-h-11 font-medium text-[var(--color-accent-strong)] underline underline-offset-2 ' +
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)] ' +
+ 'disabled:cursor-not-allowed disabled:opacity-40 xl:min-h-0'
+
/** « Point placé », « Zone tracée, 5 sommets », « Accès tracé, 3 sommets ». */
function useShapeText(pending: Creation['pending']): string {
const t = useT()
@@ -104,18 +115,14 @@ function ShapeLine({ work, readOnly }: { work: Creation; readOnly: boolean }) {
const text = useShapeText(work.pending)
const point = work.pending.kind === 'point'
return (
-
+
{text}
@@ -244,6 +251,14 @@ function useCreationReturn(work: Creation | null) {
return { created, returnFocus }
}
+/** Tells the workspace's guard dialog whether this dialog is on screen (it asks inside). */
+function useShownFlag(open: boolean) {
+ useEffect(() => {
+ useAnnotationWork.setState({ creationShown: open })
+ return () => useAnnotationWork.setState({ creationShown: false })
+ }, [open])
+}
+
/**
* « Nouveau point », « Nouvelle zone », « Nouvel accès » (board 02, 04): a modal without a
* history layer over the right column, mounted outside the edit-only body so a read-only
@@ -255,9 +270,11 @@ export default function CreationDialog(props: CreationDialogProps) {
const visible = usePlaceVisible()
const work = useAnnotationWork((s) => s.creation)
const back = useCreationReturn(work)
+ const open = visible && work !== null && work.dialog
+ useShownFlag(open)
return (