fix(editor): a tool or view chip tap keeps the focus off body

Safari focuses no tapped button: a tool or a view chip pressed after a
keyboard series commits through the guard with the focus on the handle,
then the change unmounts the handle. The focus now lands on the pressed
button, without a scroll, only when it fell to body (M-4).
This commit is contained in:
bchanot committed 2026-11-19 15:00:39 +01:00
1 parent 966ad4fe45
commit 531bbef619
4 files changed
+66 -9

No files matched your search

@@ -1356,6 +1356,46 @@ describe('Safari: the focus after a press that commits a pending series', () =>
},
)
it('a press on a tool commits with the focus kept, then focuses the tool', async () => {
await keyedVertex()
const held = vertex(1)
const seen = watchCommitFocus()
const tool = screen.getByRole('button', { name: 'Point' })
fireEvent.click(tool)
expect(pointsOf('z')![0]).toEqual([20.5, 20])
expect(seen[0]).toBe(held)
expect(tool).toHaveAttribute('aria-pressed', 'true')
expect(document.activeElement).toBe(tool)
})
it('a press on a view chip commits with the focus kept, then focuses the chip', 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 views = screen.getByRole('group', { name: 'Vues' })
const chip = within(views).getByRole('button', { name: 'Tête' })
fireEvent.click(chip)
expect(pointsOf('z')![0]).toEqual([20.5, 20])
expect(seen[0]).toBe(held)
expect(chip).toHaveAttribute('aria-pressed', 'true')
expect(document.activeElement).toBe(chip)
})
it('« Déplacer le sommet » focuses the first arrow', async () => {
await keyedVertex()
fireEvent.click(screen.getByRole('button', { name: 'Déplacer le sommet' }))