fix(editor): access shape choice shows over a kept selection

This commit is contained in:
bchanot committed 2026-11-23 17:14:44 +01:00
1 parent 9c7cbeaf13
commit 4180d5e089
2 files changed
+38 -8

No files matched your search

@@ -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 (
<AccessShapeChoice
shape={ui.accessShape}
onChange={(shape) => dispatch({ type: 'access_shape', shape })}
/>
)
}
if (selected) {
return (
<>
@@ -352,14 +362,6 @@ function SceneCommands({
/>
)
}
if (ui.tool === 'link' && !creation) {
return (
<AccessShapeChoice
shape={ui.accessShape}
onChange={(shape) => dispatch({ type: 'access_shape', shape })}
/>
)
}
if (ui.tool !== 'point' || creation || !frame) return null
return (
<ToolSize
@@ -566,6 +566,34 @@ describe('the access shapes (D5, panel 07)', () => {
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'))