fix(editor): guard keeps pending series, mode end said, R-9 hook

- guardDrawing commits a keyboard or size series the focus still holds
  (its blur) and ends only the mode: a pending series is never dropped.
- A started move ended by a selection change is said (R-13).
- handleSize: no module-level state; useHandleSizes reads the device
  once per handle layer. The layer reads ResizeObserver contentRect.
- Dead kind check removed in SelectionPointCommands; long lines wrapped
  (code, doc).
- e2e: the zoom check waits for the transform to change; the move-mode
  arrow clicks are under expectNoShift.
This commit is contained in:
bchanot committed 2026-11-17 19:25:04 +01:00
1 parent e01d8519ea
commit 463e0a2621
11 files changed
+157 -40

No files matched your search

+56 -3
View File
@@ -13,6 +13,7 @@ import userEvent from '@testing-library/user-event'
import type { Annotation } from '@faunosteo/core-wasm/types'
import AnnotationsTab from '@/components/editor/tabs/AnnotationsTab'
import { useAnnotationWork, resetWork } from '@/editor/annotations/workStore'
import { guardDrawing } from '@/editor/annotations/drawingGuard'
import { useLocaleStore } from '@/state/localeStore'
import { useUndoShortcuts } from '@/editor/useUndoShortcuts'
import {
@@ -479,7 +480,7 @@ describe('review fixes: no silent loss, no empty commit, no lost focus', () => {
}
const question = () => useAnnotationWork.getState().question?.work ?? null
it('« Tout afficher », a tool and « Ajouter un point » ask before a started move goes', async () => {
it('« Toutes les annotations », a tool and « Ajouter un point » ask first', async () => {
await started()
const panel = screen.getByTestId('annotation-properties')
fireEvent.click(
@@ -520,7 +521,7 @@ describe('review fixes: no silent loss, no empty commit, no lost focus', () => {
expect(message()).not.toHaveTextContent('Défaire')
})
it('Escape that deselects from the handle or the slider keeps the focus on the page', async () => {
it('Escape deselecting from the handle or the slider keeps a focus', async () => {
await mount(two())
await select()
handle().focus()
@@ -567,7 +568,7 @@ describe('A5 through the Point tool click', () => {
point('c', 60, 60, 9),
)
it('a click places the point at the most used size, or at the size the slider chose', async () => {
it('a click places the point at the most used size', async () => {
await mount(sized())
const user = userEvent.setup()
await user.click(screen.getByRole('button', { name: 'Point' }))
@@ -586,3 +587,55 @@ describe('A5 through the Point tool click', () => {
expect(within(panel).getByLabelText('Rayon')).toHaveValue('9')
})
})
describe('fix round 1: no silent loss on the way out', () => {
const two = () => withPoints(point('a', 50, 50, 5), point('b', 20, 20, 5))
it('a guarded navigation commits a keyboard series the handle still holds', async () => {
await mount(two())
await select()
const before = depth()
handle().focus()
fireEvent.keyDown(handle(), { key: 'ArrowRight' })
act(() => void guardDrawing(() => undefined))
expect(geometryOf('a')).toMatchObject({ cx: 50.5 })
expect(depth()).toBe(before + 1)
})
it('a pending size the focus already left is kept, not dropped', async () => {
await mount(two())
await select()
fireEvent.change(slider(), { target: { value: '7' } })
screen.getByTestId('annotation-canvas').focus()
act(() => void guardDrawing(() => undefined))
expect(useAnnotationWork.getState().preview).toMatchObject({
source: 'size',
})
})
it('a started move ended by a selection change is said, never silent', async () => {
await mount(two())
await select()
await userEvent.setup().click(moveButton())
fireEvent.click(arrow('la droite'))
const mode = useAnnotationWork.getState().mode!
act(() =>
useAnnotationWork.setState({ mode: { ...mode, annotationId: 'b' } }),
)
expect(useAnnotationWork.getState().mode).toBeNull()
expect(
await screen.findByText('Déplacement abandonné : la fiche a changé.'),
).toBeInTheDocument()
})
it('a view chip asks before a started move goes', async () => {
await mount(withLink(two(), 'l'))
await select()
await userEvent.setup().click(moveButton())
fireEvent.click(arrow('la droite'))
const views = screen.getByRole('group', { name: 'Vues' })
fireEvent.click(within(views).getByRole('button', { name: 'Tête' }))
expect(useAnnotationWork.getState().question?.work).toBe('move')
expect(screen.getByTestId('move-mode-bar')).toBeInTheDocument()
})
})