fix(editor): redo and move-mode handle keys keep pending work
Final review I-1. Redo (Ctrl+Shift+Z and the header « Refaire ») is inactive while a started move or redraw, a keyboard series or a size change is pending (holdsRedo): the work stays, the user commits or cancels it first. In a move mode, Insert and Delete on a vertex and Enter or Space on « + » and « − » do nothing, as the press machine. Tests: no assertion removed. The history-guards move-mode helper and reset run in act, since « Refaire » now re-renders on a started mode.
This commit is contained in:
1 parent
c6b8c7e48a
commit
ae80511964
7 files changed
+211
-12
No files matched your search
@@ -104,6 +104,8 @@ function vertexKey(input: ZoneEditInput, index: number, event: KeyboardEvent) {
|
||||
return inMoveMode() ? input.confirmMove() : commitKeys(input)
|
||||
}
|
||||
if (event.key !== 'Insert' && event.key !== 'Delete') return
|
||||
// Final review I-1: a move mode changes the position only, as the press machine does.
|
||||
if (inMoveMode()) return
|
||||
// I-1: arrow steps still pending are committed first; the change applies to that place.
|
||||
commitKeys(input)
|
||||
const chosen = id ? freshChosen(id) : null
|
||||
@@ -139,16 +141,17 @@ export function useZoneEdit(input: ZoneEditInput) {
|
||||
},
|
||||
// BDR-050: leaving the vertex commits its series; a move mode waits for « Valider ».
|
||||
onVertexBlur: () => commitKeys(input),
|
||||
// Final review I-1: in a move mode « + » and « − » do nothing (no click there either).
|
||||
onInsertKey: (after: number, event: KeyboardEvent) => {
|
||||
if (!isPress(event)) return
|
||||
event.preventDefault()
|
||||
insertAfter(input, after)
|
||||
if (!inMoveMode()) insertAfter(input, after)
|
||||
},
|
||||
// The bubble's own index is the chosen vertex (it is drawn only over that one).
|
||||
onRemoveKey: (_index: number, event: KeyboardEvent) => {
|
||||
if (!isPress(event)) return
|
||||
event.preventDefault()
|
||||
deleteChosen(input)
|
||||
if (!inMoveMode()) deleteChosen(input)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +155,16 @@ export function cancelPending(): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Work a redo would drop without a word (final review I-1): a started mode, a keyboard
|
||||
* series or a slider change. Redo waits until it is committed or cancelled; an unstarted
|
||||
* mode loses nothing and does not hold it.
|
||||
*/
|
||||
export function holdsRedo(work: Pick<Work, 'mode' | 'preview'>): boolean {
|
||||
if (work.mode?.started) return true
|
||||
return work.preview !== null && work.preview.source !== 'move'
|
||||
}
|
||||
|
||||
const fresh = <T extends { base: string }>(item: T | null, text: string) =>
|
||||
item && item.base !== text ? null : item
|
||||
|
||||
|
||||
Reference in new issue
Block a user