fix(editor): focus follows the action after a touch commit

This commit is contained in:
bchanot committed 2026-11-19 11:26:37 +01:00
1 parent df46390bdb
commit 03e85a7c67
5 files changed
+135 -4

No files matched your search

@@ -1292,3 +1292,58 @@ describe('Safari: a strip command clicked with the focus left on a keyed vertex'
expect(depth()).toBe(before + 1)
})
})
describe('Safari: the focus after a press that commits a pending series', () => {
// A tap that moves no focus (jsdom moves none either): the commit must not send the focus
// to body, and the press lands it where the same action sends it from the keyboard.
async function keyedVertex() {
await mount(squareText())
await select()
clickHandle('Sommet 1 de N', [20, 20])
act(() => vertex(1).focus())
fireEvent.keyDown(vertex(1), { key: 'ArrowRight' })
expect(useAnnotationWork.getState().preview?.source).toBe('keys')
}
it('a press on another vertex commits the series and focuses that vertex', async () => {
await keyedVertex()
const before = depth()
clickHandle('Sommet 2 de N', [80, 20])
expect(depth()).toBe(before + 1)
expect(pointsOf('z')![0]).toEqual([20.5, 20])
expect(document.activeElement).toBe(vertex(2))
})
it('a press on the interior keeps the focus on the handle that held the series', async () => {
await keyedVertex()
const before = depth()
pressAt(marker('z'), 50, 50)
expect(depth()).toBe(before + 1)
expect(document.activeElement).toBe(vertex(1))
})
it('a press on « + » commits the series and keeps a vertex focused', async () => {
await keyedVertex()
clickHandle('Ajouter un sommet après le sommet 1 de N', [50, 20])
expect(document.activeElement).not.toBe(document.body)
expect(document.activeElement?.getAttribute('data-vertex')).not.toBeNull()
})
it('« Redessiner » and « Déplacer le sommet » never leave it on body', async () => {
await keyedVertex()
fireEvent.click(screen.getByRole('button', { name: 'Déplacer le sommet' }))
expect(document.activeElement).not.toBe(document.body)
cleanup()
resetStore()
resetWork()
await keyedVertex()
fireEvent.click(screen.getByRole('button', { name: 'Redessiner' }))
expect(document.activeElement).not.toBe(document.body)
})
it('« Désélectionner » focuses the row, as its key does', async () => {
await keyedVertex()
fireEvent.click(screen.getByRole('button', { name: 'Désélectionner' }))
expect(document.activeElement).not.toBe(document.body)
})
})