fix(app): crossing focus for any element in a hidden part

Focus held by any element that a crossing hides or unmounts (button, tool,
canvas, link) goes to the shown tab, decided by the element leaving the page,
not by tag; a field still commits first; visible focus stays.
History pair: remembered field must be connected, and a pointer-down off a
field keeps it. TextField.commit compares with the latest committed value.
Open-panel axe settles and checks dialogs like the other places.

R-24: no assertion rewritten or deleted; one Chromium case and three unit
tests added.
This commit is contained in:
bchanot committed 2026-11-08 20:43:27 +01:00
1 parent a474ddaa40
commit 606f7ba268
8 files changed
+81 -18

No files matched your search

@@ -260,6 +260,36 @@ describe('the guards of a width change', () => {
expect(document.activeElement).toBe(button('Plus'))
})
it('a focused button of a hidden part hands its focus to the shown tab', async () => {
const user = await mount()
await user.click(tab('Annotations'))
await user.click(button('Modifier les catégories'))
const add = button('Ajouter la catégorie')
act(() => add.focus())
cross(800)
expect(add.closest('[hidden]')).not.toBeNull()
expect(document.activeElement).toBe(tab('Annotations'))
})
it('a focused drawing tool hands its focus to the shown tab', async () => {
const user = await mount()
await waitFor(() =>
expect(button('Zone')).toBeEnabled(),
)
await user.click(button('Zone'))
expect(document.activeElement).toBe(button('Zone'))
cross(800)
expect(document.activeElement).toBe(tab('Annotations'))
})
it('a focused header button stays where it is', async () => {
await mount()
const refs = button('Références')
act(() => refs.focus())
cross(800)
expect(document.activeElement).toBe(refs)
})
it('a crossing with the focus on no field leaves the focus alone', async () => {
const user = await mount()
await user.click(tab('Général'))