Task 5 review fix round 1. - I-1: Insert and Delete on a vertex commit pending arrow steps first, then act on the stored polygon (read from the store, not the render). - I-2: deselect commits a handle's pending series before the handle unmounts (commitFocusedSeries, no reliance on blur at removal). - I-3: a touch or pen tap absorbs the click the browser synthesises at its place, once, within 400 ms and 8 px; mouse and later clicks pass. Scroll anchoring is off while the editor shows: the deselect's panel swap scrolled the drawing under the finger. editor-deselect step c is back at the page's end, and asserts the drawing does not move. - I-4, M-2: the double-click and undo tests press what is there now; a hand-set stale chosen vertex removes nothing. - I-5: editor-zones undos, the vertex choice and the refused-trace clicks run under expectNoShift; new e2e for I-2. - M-1: Delete on the last vertex and Enter on « − » keep the focus on a vertex (the next one is chosen). - M-4: the strip notice comment names R-18. M-5: the tracing carries a `refused` flag; only a refused close titles « Fermeture refusée ». - M-7: TODO lines (bubble size shortcut, scroll-padding-top, scroll clamp at the page's end). Rewritten assertions: zone-edit « − » double click and undo-then-« − » pressed the detached bubble -> press the live bubble or the box at the same place. editor-deselect step c: scroll-to-top removed, drawing y asserted unchanged. editor-geometry: scroll-to-top kept with the clamp named (reported, TODO). editor-zones and editor-journey: comment says the scroll-to-top undoes Playwright's own auto-scroll.
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { endMode, guardWork, useAnnotationWork } from './workStore'
|
|
|
|
/**
|
|
* A keyboard series or a size change still pending (no blur yet: a mouse Back button)
|
|
* commits now, through its own blur (BDR-050): leaving never drops it.
|
|
*/
|
|
export function commitFocusedSeries(): void {
|
|
const { preview } = useAnnotationWork.getState()
|
|
if (!preview || preview.source === 'move') return
|
|
const active = document.activeElement
|
|
const series = active instanceof HTMLElement || active instanceof SVGElement
|
|
if (series && active.closest('[data-series]')) active.blur()
|
|
}
|
|
|
|
/** An unstarted mode ends; a pending series that is not the mode's stays. */
|
|
function endModeOnly(): void {
|
|
useAnnotationWork.setState((work) => ({
|
|
mode: null,
|
|
preview: work.preview?.source === 'move' ? null : work.preview,
|
|
}))
|
|
}
|
|
|
|
/**
|
|
* The drawing guard (R-12), asked by every navigation that would drop the drawing's work:
|
|
* a tab, a section, « Aller à », a view chip, a tool, Back, leaving the editor. Nothing
|
|
* started: an unstarted mode ends at once and the caller goes on (true). Work started:
|
|
* the question is shown (`DrawingGuardDialog`) and `proceed` waits for « Abandonner »
|
|
* (false).
|
|
*/
|
|
export function guardDrawing(proceed: () => void): boolean {
|
|
const work = guardWork(useAnnotationWork.getState())
|
|
if (work === null) {
|
|
commitFocusedSeries()
|
|
endModeOnly()
|
|
return true
|
|
}
|
|
useAnnotationWork.setState({ question: { work, proceed } })
|
|
return false
|
|
}
|
|
|
|
/** « Continuer » keeps the work as it is; « Abandonner » drops it and makes the move. */
|
|
export function answerDrawing(discard: boolean): void {
|
|
const { question } = useAnnotationWork.getState()
|
|
useAnnotationWork.setState({ question: null })
|
|
if (!discard || !question) return
|
|
endMode()
|
|
question.proceed()
|
|
}
|