fix(editor): an overview row tap keeps the focus off body

This commit is contained in:
bchanot committed 2026-11-19 16:16:30 +01:00
1 parent 0aa0f6bc62
commit 8b190b4e0d
4 files changed
+73 -16

No files matched your search

@@ -1402,6 +1402,55 @@ describe('Safari: the focus after a press that commits a pending series', () =>
expect(document.activeElement).toBe(chip)
})
it('a press on another annotation row commits with the focus kept, then focuses the row', async () => {
// A point has no vertex handle: selecting it unmounts the focused vertex.
const other = insert(squareText(), point('y', 50, 50, 1))
await mount(other)
await select()
clickHandle('Sommet 1 de N', [20, 20])
act(() => vertex(1).focus())
fireEvent.keyDown(vertex(1), { key: 'ArrowRight' })
const held = vertex(1)
const seen = watchCommitFocus()
const list = screen.getByRole('list', { name: 'Annotations de la vue' })
const row = within(list)
.getAllByRole('button')
.find((button) => button.getAttribute('aria-current') !== 'true')!
fireEvent.click(row)
expect(pointsOf('z')![0]).toEqual([20.5, 20])
expect(seen[0]).toBe(held)
expect(row).toHaveAttribute('aria-current', 'true')
expect(document.activeElement).toBe(row)
})
it('a press on a view row commits with the focus kept, then focuses the row', async () => {
const detail = insert(squareText(), {
kind: 'view',
value: {
kind: 'detail',
id: 'view-det',
name: { fr: 'Tête', en: 'Head' },
svg_asset_id: null,
view_box: { min_x: 10, min_y: 10, width: 80, height: 80 },
parent_view_id: 'view-main',
},
})
await mount(detail)
await select()
clickHandle('Sommet 1 de N', [20, 20])
act(() => vertex(1).focus())
fireEvent.keyDown(vertex(1), { key: 'ArrowRight' })
const held = vertex(1)
const seen = watchCommitFocus()
const card = screen.getByRole('region', { name: 'Vues' })
const row = within(card).getByRole('button', { name: /Tête/ })
fireEvent.click(row)
expect(pointsOf('z')![0]).toEqual([20.5, 20])
expect(seen[0]).toBe(held)
expect(row).toHaveAttribute('aria-current', 'true')
expect(document.activeElement).toBe(row)
})
it('« Déplacer le sommet » focuses the first arrow', async () => {
await keyedVertex()
fireEvent.click(screen.getByRole('button', { name: 'Déplacer le sommet' }))