From 4180d5e089283b6b84ec9a16decf2d2f8b6e54aa Mon Sep 17 00:00:00 2001 From: bchanot Date: Mon, 23 Nov 2026 17:14:44 +0100 Subject: [PATCH] fix(editor): access shape choice shows over a kept selection --- .../editor/annotations/SceneStrip.tsx | 18 ++++++------ .../tests/unit/editor-add-buttons.test.tsx | 28 +++++++++++++++++++ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/apps/app/src/components/editor/annotations/SceneStrip.tsx b/apps/app/src/components/editor/annotations/SceneStrip.tsx index b3f85f33..fd9d2b8e 100644 --- a/apps/app/src/components/editor/annotations/SceneStrip.tsx +++ b/apps/app/src/components/editor/annotations/SceneStrip.tsx @@ -125,6 +125,7 @@ function commandsKeyOf( if (creation?.resumed) return `creation-${creation.pending.geometry.type}` if (tracing) return 'tracing' if (moving) return 'move' + if (ui.tool === 'link') return 'tool-link' if (access) return 'access' if (target?.geometry?.type === 'polygon') return `zone-${chosen !== null}` if (target?.kind === 'point') return 'point' @@ -323,6 +324,15 @@ function SceneCommands({ /> ) } + // The armed access tool keeps its shape choice over a kept selection (D5). + if (ui.tool === 'link' && !creation) { + return ( + dispatch({ type: 'access_shape', shape })} + /> + ) + } if (selected) { return ( <> @@ -352,14 +362,6 @@ function SceneCommands({ /> ) } - if (ui.tool === 'link' && !creation) { - return ( - dispatch({ type: 'access_shape', shape })} - /> - ) - } if (ui.tool !== 'point' || creation || !frame) return null return ( { expect(screen.queryByTestId('access-shape')).toBeNull() }) + it("shows the choice over a kept selection, and the selection's commands come back", async () => { + const text = insert(withDetail(), { + kind: 'annotation', + value: { + ...(point('zone-a', 0, 0, 1).value as Annotation), + kind: 'zone', + geometry: { type: 'polygon', points: SQUARE }, + name: { fr: 'N', en: 'N' }, + }, + } as never) + const user = await mount(text) + const list = await screen.findByRole('list', { + name: 'Annotations de la vue', + }) + await user.click(within(list).getAllByRole('button')[0]) + await screen.findByRole('button', { name: 'Propriétés' }) + await user.click(tool('Accès à une vue détaillée')) + expect( + screen.getByRole('radiogroup', { name: "Forme de l'accès" }), + ).toBeTruthy() + await user.click(shapeRadio('Polygone')) + expect(shapeRadio('Polygone')).toBeChecked() + expect(status()).toHaveTextContent('Outil Accès armé, forme Polygone.') + await user.click(tool('Sélectionner et déplacer')) + expect(screen.queryByTestId('access-shape')).toBeNull() + expect(screen.getByRole('button', { name: 'Propriétés' })).toBeTruthy() + }) + it('keeps the last choice when the tool is armed again', async () => { const user = await armed() await user.click(shapeRadio('Cercle'))