fix(editor): no lost series, tap click absorbed, focus kept on handles

Task 5 review fix round 1.
- I-1: Insert and Delete on a vertex commit pending arrow steps first,
  then act on the stored polygon (read from the store, not the render).
- I-2: deselect commits a handle's pending series before the handle
  unmounts (commitFocusedSeries, no reliance on blur at removal).
- I-3: a touch or pen tap absorbs the click the browser synthesises at
  its place, once, within 400 ms and 8 px; mouse and later clicks pass.
  Scroll anchoring is off while the editor shows: the deselect's panel
  swap scrolled the drawing under the finger. editor-deselect step c is
  back at the page's end, and asserts the drawing does not move.
- I-4, M-2: the double-click and undo tests press what is there now;
  a hand-set stale chosen vertex removes nothing.
- I-5: editor-zones undos, the vertex choice and the refused-trace
  clicks run under expectNoShift; new e2e for I-2.
- M-1: Delete on the last vertex and Enter on « − » keep the focus on a
  vertex (the next one is chosen).
- M-4: the strip notice comment names R-18. M-5: the tracing carries a
  `refused` flag; only a refused close titles « Fermeture refusée ».
- M-7: TODO lines (bubble size shortcut, scroll-padding-top, scroll
  clamp at the page's end).

Rewritten assertions: zone-edit « − » double click and undo-then-« − »
pressed the detached bubble -> press the live bubble or the box at the
same place. editor-deselect step c: scroll-to-top removed, drawing y
asserted unchanged. editor-geometry: scroll-to-top kept with the clamp
named (reported, TODO). editor-zones and editor-journey: comment says
the scroll-to-top undoes Playwright's own auto-scroll.
This commit is contained in:
bchanot committed 2026-11-17 21:04:23 +01:00
1 parent 316d8c475c
commit e596e0765e
17 files changed
+395 -57

No files matched your search

@@ -511,7 +511,8 @@ function SceneCommands({ scene, work }: { scene: Scene; work: Work }) {
/**
* The strip's middle, first match wins: a refusal (the strip's own, then a refused gesture
* whose line under the drawing may be cut short: its full text here, A6), the selection's
* geometry issues (the first, then « +n »), then why a tool cannot be used now.
* geometry issues (the first, then « +n »), R-18's zoom line for a hidden « + », then why
* a tool cannot be used now.
*/
function useStripNotice(
scene: Scene,
@@ -243,19 +243,38 @@ function useChosen(annotationId: string, count: number): number | null {
})
}
/** Whether the focus is on this group, or fell to the page from it (its handle unmounted). */
function focusIsOurs(group: SVGGElement, held: boolean): boolean {
const active = document.activeElement
if (group.contains(active)) return true
const fell =
active === null || active === document.body || !active.isConnected
return held && fell
}
/**
* A keyboard choice (« + », Insert, Delete) moves the focus to the vertex now chosen, so
* the keys keep acting where the user looks; a pointer choice leaves the focus alone.
* A keyboard choice (« + », Insert, Delete, Enter on « − ») moves the focus to the vertex
* now chosen, so the keys keep acting where the user looks, even when the focused handle
* was removed; a pointer choice leaves the focus alone. It follows every new choice (the
* store's object), a re-choice of the same index on a new text included.
*/
function useFocusFollowsChoice(chosen: number | null) {
const group = useRef<SVGGElement | null>(null)
const held = useRef(false)
const choice = useAnnotationWork((s) => s.chosen)
useLayoutEffect(() => {
const element = group.current
if (chosen === null || !element || !focusIsOurs(element, held.current))
return
const active = document.activeElement
if (chosen === null || !group.current?.contains(active)) return
if (active?.getAttribute('data-vertex') === String(chosen)) return
const target = group.current.querySelector(`[data-vertex="${chosen}"]`)
const target = element.querySelector(`[data-vertex="${chosen}"]`)
if (target instanceof SVGElement) target.focus()
}, [chosen])
}, [chosen, choice])
// Read after every commit: where the focus was before the next change unmounts it.
useLayoutEffect(() => {
held.current = group.current?.contains(document.activeElement) ?? false
})
return group
}