fix(editor): vertex keys act on the focused handle after an undo

This commit is contained in:
bchanot committed 2026-11-19 11:20:19 +01:00
1 parent 6df66f9bb9
commit df46390bdb
3 files changed
+47 -11

No files matched your search

+30 -2
View File
@@ -223,7 +223,7 @@ describe('a vertex (R-9)', () => {
).toBeNull()
void bubble
const after = depth()
fireEvent.keyDown(vertex(2), { key: 'Delete' })
// (A vertex key acts on its own handle, so it is not a stale case; only the bubble is.)
// A press where the bubble was reaches what is there now: a bubble still shown, else the
// box (which deselects).
pressAt(liveBubbleOrCanvas(), 50, 20)
@@ -254,6 +254,25 @@ describe('a vertex (R-9)', () => {
expect(depth()).toBe(before + 2)
})
it('Backspace, undo, Backspace on the same focused vertex deletes again; so does « + »', async () => {
await mount(squareText())
render(<UndoKeys />)
await select()
vertex(2).focus()
fireEvent.keyDown(vertex(2), { key: 'Backspace' })
expect(pointsOf('z')).toHaveLength(3)
fireEvent.keyDown(document.body, { key: 'z', ctrlKey: true })
expect(pointsOf('z')).toEqual(SQUARE)
expect(chosen()).toBeNull()
fireEvent.keyDown(vertex(2), { key: 'Backspace' })
expect(pointsOf('z')).toHaveLength(3)
fireEvent.keyDown(document.body, { key: 'z', ctrlKey: true })
expect(chosen()).toBeNull()
fireEvent.keyDown(vertex(2), { key: '+' })
expect(pointsOf('z')).toHaveLength(5)
expect(chosen()).toMatchObject({ vertex: 2 })
})
it('Backspace at three vertices keeps them with the reason; « + » needs no drawn « + »', async () => {
await mount(squareText(SQUARE.slice(0, 3)))
await select()
@@ -793,7 +812,6 @@ describe('fix round 1: no lost series, no lost focus, no stale « − »', () =>
chosen: { annotationId: 'z', vertex: 1, base: 'an older text' },
}),
)
fireEvent.keyDown(vertex(2), { key: 'Delete' })
pressAt(liveBubbleOrCanvas(), 80, 10)
expect(pointsOf('z')).toEqual(SQUARE)
expect(depth()).toBe(before)
@@ -908,6 +926,14 @@ describe('the zoom hint for short segments (R-18, D2)', () => {
)
})
it('« + » on the canvas box itself still zooms', async () => {
await mount(squareText(SHORT))
await select()
fireEvent.keyDown(screen.getByTestId('annotation-canvas'), { key: '+' })
fireEvent.keyDown(screen.getByTestId('annotation-canvas'), { key: '+' })
await waitFor(() => expect(plus(1)).toBeInTheDocument())
})
it('a refusal takes its place while shown', async () => {
await mount(squareText(SHORT))
await select()
@@ -1093,6 +1119,8 @@ describe('final review I-1: a redo or a handle key never drops pending work', ()
fireEvent.keyDown(minus(3), { key: 'Enter' })
fireEvent.keyDown(vertex(3), { key: 'Insert' })
fireEvent.keyDown(vertex(3), { key: 'Delete' })
expect(fireEvent.keyDown(vertex(3), { key: 'Backspace' })).toBe(true)
expect(fireEvent.keyDown(vertex(3), { key: '+' })).toBe(true)
fireEvent.keyDown(plus(2), { key: 'Enter' })
expect(pointsOf('z')).toEqual(SQUARE)
expect(depth()).toBe(before)