Files
faunosteo/apps/app/src/components/editor/annotations/DrawingGuardDialog.tsx
T
bchanot 837ec9f436 fix(editor): slider while replacing, announced drop, review minors
Task 7 fix round 1 (review task-7-review.md).
- Important 1: « Taille » shows beside « Revenir aux propriétés » while
  a point is replaced (still hidden under the modal dialog); it feeds
  the hover preview and the re-placed point (R-10).
- Important 2: a creation whose view leaves the document is dropped
  and said, « Création abandonnée : la fiche a changé. » (dropped:
  'creation', read by useDroppedNotice).
- Minor 3: DrawingGuardDialog leaves a creation question to the
  creation dialog only while that dialog is really on screen
  (creationShown, set by the dialog).
- Minor 7: the dialog's long className strings split into constants.
- Minor 8: dead TOOL_OF removed; trace_start is a redraw's only.

Tests added (no assertion removed): slider while replacing (unit,
RED then GREEN; e2e under expectNoShift at three widths, last strip
command inside the strip); view removed during a creation (RED then
GREEN); question shown by the workspace when the dialog is not on
screen (RED then GREEN); « Abandonner » while read-only; R-13 with a
restored copy during a started move; leaving the route resets the
work (fails with the session reset removed). The unit Back test's
comment is corrected: it does pin the modal branch.
2026-11-18 00:06:16 +01:00

32 lines
1.2 KiB
TypeScript

import { useRef } from 'react'
import { answerDrawing } from '@/editor/annotations/drawingGuard'
import { useAnnotationWork } from '@/editor/annotations/workStore'
import { useT } from '@/i18n/useT'
import ConfirmDialog from '../ConfirmDialog'
/**
* The drawing guard's question (R-12), mounted with the workspace so it shows whatever
* tab is in view: « Continuer » keeps the work, « Abandonner » drops it and makes the move
* that was held. The creation dialog, when shown, asks it in its own footer instead.
*/
export default function DrawingGuardDialog() {
const t = useT()
// Over a shown creation dialog the question is that dialog's own (R-12, board 31 D).
const question = useAnnotationWork((s) =>
s.question?.work === 'creation' && s.creationShown ? null : s.question,
)
// The title stays while the dialog closes.
const title = useRef('')
if (question) title.current = t(`editor.annotations.guard.${question.work}`)
return (
<ConfirmDialog
open={question !== null}
title={title.current}
confirmLabel={t('editor.annotations.guard.discard')}
cancelLabel={t('editor.annotations.guard.continue')}
onConfirm={() => answerDrawing(true)}
onCancel={() => answerDrawing(false)}
/>
)
}