fix(app): focus the shown tab after a crossing, one commit per typed field

- A field blurred by a 1 024 px crossing or a read-only switch hands its
  focus to the shown tab (or Plus), never to body (focusRequest, useViewport).
- TextField no longer commits a blurred value twice when it unmounts before
  the render that brings the new value: one undo step, one count.
- Annuler and Retablir share the field left by Tab, so Shift+Tab to Annuler
  and Enter still skips the undo of a refused field.
- Adding a reference clears the finding filter and the search.

Unit tests: no-loss (focus on tab and on Plus, one undo entry), history
buttons (field kept across the pair), references panel (add clears, refused
add keeps).
This commit is contained in:
bchanot committed 2026-11-08 20:23:40 +01:00
1 parent 9c03cf2413
commit 0bb150f860
9 files changed
+149 -29

No files matched your search

@@ -245,9 +245,27 @@ describe('the guards of a width change', () => {
fireEvent.change(field, { target: { value: 'Nom saisi' } })
expect(store.getState().unsaved).toBe(false)
cross(800)
expect(store.getState().undo).toHaveLength(1)
expect(JSON.parse(store.getState().documentText).name.fr).toBe('Nom saisi')
expect(store.getState().unsaved).toBe(true)
await waitFor(() => expect(storedCopy()).not.toBeNull())
expect(document.activeElement).toBe(tab('Général'))
})
it('the focus of a typed field goes to « Plus » when the shown tab left the row', async () => {
const user = await mount()
await user.click(tab('Général'))
await user.click(byId('general-name-fr'))
cross(500)
expect(document.activeElement).toBe(button('Plus'))
})
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'))
;(document.activeElement as HTMLElement).blur()
cross(800)
expect(document.activeElement).toBe(document.body)
})
it('a field that switches in place loses a refused value, a field of a kept part keeps it', async () => {