fix(editor): guard keeps pending series, mode end said, R-9 hook
- guardDrawing commits a keyboard or size series the focus still holds (its blur) and ends only the mode: a pending series is never dropped. - A started move ended by a selection change is said (R-13). - handleSize: no module-level state; useHandleSizes reads the device once per handle layer. The layer reads ResizeObserver contentRect. - Dead kind check removed in SelectionPointCommands; long lines wrapped (code, doc). - e2e: the zoom check waits for the transform to change; the move-mode arrow clicks are under expectNoShift.
This commit is contained in:
1 parent
e01d8519ea
commit
463e0a2621
11 files changed
+157
-40
No files matched your search
@@ -1,5 +1,25 @@
|
||||
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.
|
||||
*/
|
||||
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
|
||||
@@ -10,7 +30,8 @@ import { endMode, guardWork, useAnnotationWork } from './workStore'
|
||||
export function guardDrawing(proceed: () => void): boolean {
|
||||
const work = guardWork(useAnnotationWork.getState())
|
||||
if (work === null) {
|
||||
endMode()
|
||||
commitFocusedSeries()
|
||||
endModeOnly()
|
||||
return true
|
||||
}
|
||||
useAnnotationWork.setState({ question: { work, proceed } })
|
||||
|
||||
Reference in new issue
Block a user