fix(editor): give the focus back to « Redessiner » after a redraw
Final review M-6. useMoveFocusReturn becomes useModeFocusReturn: the mode that ended picks its entry, « Déplacer … » (data-move-entry) for a move, « Redessiner » or « Remplacer par un polygone » (data-redraw-entry) for a redraw, the drawing when neither is shown. A redraw counts as running while its mode or its tracing lives, so a link polygon (no « Déplacer ») never leaves the focus on body. Tests: no assertion removed.
This commit is contained in:
1 parent
323a342586
commit
e299c3d4f6
4 files changed
+121
-14
No files matched your search
@@ -1005,3 +1005,83 @@ describe('final review I-1: a redo or a handle key never drops pending work', ()
|
||||
expect(screen.queryByText(ABANDONED)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('final review M-6: a redraw gives the focus back to « Redessiner »', () => {
|
||||
const canvas = () => screen.getByTestId('annotation-canvas')
|
||||
const TRACE: [number, number][] = [
|
||||
[30, 30],
|
||||
[70, 30],
|
||||
[70, 70],
|
||||
[30, 70],
|
||||
]
|
||||
const redrawButton = () => screen.getByRole('button', { name: 'Redessiner' })
|
||||
async function redrawing(text = squareText()) {
|
||||
await mount(text)
|
||||
await select()
|
||||
await userEvent.setup().click(redrawButton())
|
||||
}
|
||||
const press = (name: string) =>
|
||||
userEvent.setup().click(screen.getByRole('button', { name }))
|
||||
|
||||
it('after « Annuler le tracé »', async () => {
|
||||
await redrawing()
|
||||
pressAt(canvas(), 30, 30)
|
||||
await press('Annuler le tracé')
|
||||
expect(useAnnotationWork.getState().mode).toBeNull()
|
||||
expect(document.activeElement).toBe(redrawButton())
|
||||
})
|
||||
|
||||
it('after a closed redraw', async () => {
|
||||
await redrawing()
|
||||
TRACE.forEach(([x, y]) => pressAt(canvas(), x, y))
|
||||
await press('Fermer le tracé')
|
||||
expect(pointsOf('z')).toEqual(TRACE)
|
||||
expect(document.activeElement).toBe(redrawButton())
|
||||
})
|
||||
|
||||
it('after a refused close, then « Annuler le tracé »', async () => {
|
||||
await redrawing()
|
||||
for (const [x, y] of [
|
||||
[20, 50],
|
||||
[80, 50],
|
||||
[80, 50.5],
|
||||
])
|
||||
pressAt(canvas(), x, y)
|
||||
await press('Fermer le tracé')
|
||||
expect(useAnnotationWork.getState().mode?.started).toBe(true)
|
||||
await press('Annuler le tracé')
|
||||
expect(document.activeElement).toBe(redrawButton())
|
||||
})
|
||||
|
||||
it('on a link polygon (no « Déplacer »), never on body', async () => {
|
||||
const head = insert(drawnText(), {
|
||||
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',
|
||||
},
|
||||
})
|
||||
const link = {
|
||||
id: 'l',
|
||||
view_id: 'view-main',
|
||||
category_id: 'cat-a',
|
||||
laterality: 'unpaired',
|
||||
geometry: { type: 'polygon', points: SQUARE },
|
||||
review_status: 'to_confirm',
|
||||
color: null,
|
||||
kind: 'detail_trigger',
|
||||
name: null,
|
||||
opens_view_id: 'view-det',
|
||||
} as Annotation
|
||||
await redrawing(insert(head, { kind: 'annotation', value: link }))
|
||||
expect(screen.queryByRole('button', { name: /^Déplacer/ })).toBeNull()
|
||||
pressAt(canvas(), 30, 30)
|
||||
await press('Annuler le tracé')
|
||||
expect(document.activeElement).not.toBe(document.body)
|
||||
expect(document.activeElement).toBe(redrawButton())
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user