fix(editor): return the focus without a scroll; drop an inert tap
Final review M-4 and M-6: the line's « Défaire » focuses the drawing through focusDrawing (preventScroll), and a mode's end focuses its entry with preventScroll, so neither scrolls the page (A14). M-8: the empty tap kept after the removed click was as inert; gone. Tests removed: in « a mouse tap deselects at the pointer-up », the second pointerDown/pointerUp on the empty drawing and its repeated isDeselected assertion (the first tap's assertion covers it).
This commit is contained in:
1 parent
10a8767527
commit
a6685a04e0
3 files changed
+11
-12
No files matched your search
@@ -1,16 +1,15 @@
|
|||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
import { useEditorReadOnly } from '@/editor/editingContext'
|
import { useEditorReadOnly } from '@/editor/editingContext'
|
||||||
import { visibleElement } from '@/editor/focusRequest'
|
|
||||||
import type {
|
import type {
|
||||||
GestureMessage as Shown,
|
GestureMessage as Shown,
|
||||||
GestureMessages,
|
GestureMessages,
|
||||||
} from '@/editor/annotations/useGestureMessage'
|
} from '@/editor/annotations/useGestureMessage'
|
||||||
|
import { focusDrawing } from '@/editor/annotations/deselect'
|
||||||
import { canUndo, useEditorStore } from '@/editor/state/editorStore'
|
import { canUndo, useEditorStore } from '@/editor/state/editorStore'
|
||||||
import {
|
import {
|
||||||
cancelPending,
|
cancelPending,
|
||||||
useAnnotationWork,
|
useAnnotationWork,
|
||||||
} from '@/editor/annotations/workStore'
|
} from '@/editor/annotations/workStore'
|
||||||
import { CANVAS_BOX } from '@/editor/useEditorNavigation'
|
|
||||||
import { useT } from '@/i18n/useT'
|
import { useT } from '@/i18n/useT'
|
||||||
|
|
||||||
const PILL =
|
const PILL =
|
||||||
@@ -30,8 +29,9 @@ function undoLast(readOnly: boolean): void {
|
|||||||
const store = useEditorStore.getState()
|
const store = useEditorStore.getState()
|
||||||
if (readOnly || cancelPending() || !canUndo(store)) return
|
if (readOnly || cancelPending() || !canUndo(store)) return
|
||||||
store.undoStep()
|
store.undoStep()
|
||||||
// M-4: the undo closes the pill under the focus; the drawing takes it (WCAG 2.4.3).
|
// M-4: the undo closes the pill under the focus; the drawing takes it (WCAG 2.4.3),
|
||||||
visibleElement(CANVAS_BOX)?.focus()
|
// without a scroll (A14).
|
||||||
|
focusDrawing()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useEffect, useRef, type Dispatch } from 'react'
|
import { useEffect, useRef, type Dispatch } from 'react'
|
||||||
import { visibleElement } from '@/editor/focusRequest'
|
import { visibleElement } from '@/editor/focusRequest'
|
||||||
import { CANVAS_BOX } from '@/editor/useEditorNavigation'
|
|
||||||
import type {
|
import type {
|
||||||
Annotation,
|
Annotation,
|
||||||
AnatomicalSheetDocument,
|
AnatomicalSheetDocument,
|
||||||
} from '@faunosteo/core-wasm/types'
|
} from '@faunosteo/core-wasm/types'
|
||||||
import Button from '@/components/ui/Button'
|
import Button from '@/components/ui/Button'
|
||||||
|
import { focusDrawing } from '@/editor/annotations/deselect'
|
||||||
import { defaultRadius, type Frame } from '@/editor/annotations/frame'
|
import { defaultRadius, type Frame } from '@/editor/annotations/frame'
|
||||||
import {
|
import {
|
||||||
newPointSize,
|
newPointSize,
|
||||||
@@ -88,8 +88,10 @@ export function useModeFocusReturn(mode: FocusMode) {
|
|||||||
const ended = was.current
|
const ended = was.current
|
||||||
was.current = mode
|
was.current = mode
|
||||||
if (ended === null || mode !== null || !lost) return
|
if (ended === null || mode !== null || !lost) return
|
||||||
const entry = visibleElement(ENTRY[ended]) ?? visibleElement(CANVAS_BOX)
|
// No scroll either way (A14): the strip's command, else the drawing.
|
||||||
entry?.focus()
|
const entry = visibleElement(ENTRY[ended])
|
||||||
|
if (entry) entry.focus({ preventScroll: true })
|
||||||
|
else focusDrawing()
|
||||||
}, [mode])
|
}, [mode])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1553,14 +1553,11 @@ describe('a tap on the drawing (D6b)', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Final review M-8: since T2 a `click` on the canvas does nothing, so the click this test
|
// Final review M-8: since T2 a `click` on the canvas does nothing, so the click this test
|
||||||
// fired on a marker could not change the outcome; it is gone, the taps are the test.
|
// fired on a marker (and the empty tap before it) could not change the outcome: gone.
|
||||||
it('a mouse tap deselects at the pointer-up; another tap on the empty drawing keeps it so', async () => {
|
it('a mouse tap deselects at the pointer-up', async () => {
|
||||||
await selected({ text: insert(text(), named('anno-b', 90, 90, 3)) })
|
await selected({ text: insert(text(), named('anno-b', 90, 90, 3)) })
|
||||||
tap(rect(), { upOn: rect() })
|
tap(rect(), { upOn: rect() })
|
||||||
expect(isDeselected()).toBe(true)
|
expect(isDeselected()).toBe(true)
|
||||||
fireEvent.pointerDown(rect(), { ...init(), clientX: 10, clientY: 10 })
|
|
||||||
fireEvent.pointerUp(rect(), { ...init(), clientX: 10, clientY: 10 })
|
|
||||||
expect(isDeselected()).toBe(true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('a press on a polygon vertex handle outside its fill deselects (documented)', async () => {
|
it('a press on a polygon vertex handle outside its fill deselects (documented)', async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user