From 13e2503e6a5bb3c23cb07425c0fb49f5a5cc5b08 Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 18 Nov 2026 13:00:22 +0100 Subject: [PATCH] =?UTF-8?q?fix(editor):=20gesture=20line=20alerts,=20focus?= =?UTF-8?q?=20after=20=C2=AB=20D=C3=A9faire=20=C2=BB,=20hit=20area?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Final review M-3, M-4, M-5, M-8. - M-3: the line and the strip render a refusal's role="alert" beside their always-mounted role="status" region, never inside it; every shown message carries a serial that keys its pill, so a repeated identical refusal is a new pill and is announced again. - M-4: after the line's « Défaire » the focus goes to the canvas box. - M-5: « Défaire » gets a transparent ::before, 44 px tall below xl (36 px from xl), within the row's reserved 44 px: the pill keeps its 36 px. The A14 e2e checks the hit area at 1024, 1180, 1280 px. - M-8: the « swallows the click on a marker » test fired a click the canvas ignores since T2; the inert click is dropped, the title says what the taps prove. Tests rewritten: « the message sits on its own row »: role="status" on the row → a role="status" region inside the row, empty at rest. « a mouse tap deselects … swallows the click »: the final fireEvent.click on the marker removed (inert), its isDeselected assertion kept after the second tap. --- apps/app/e2e/shell/editor-annotations.spec.ts | 24 +++++++ .../editor/annotations/EditStrip.tsx | 17 +++-- .../editor/annotations/GestureMessage.tsx | 66 ++++++++++++++----- .../editor/annotations/useGestureMessage.ts | 9 +++ .../unit/editor-annotations-tab.test.tsx | 55 +++++++++++++++- 5 files changed, 143 insertions(+), 28 deletions(-) diff --git a/apps/app/e2e/shell/editor-annotations.spec.ts b/apps/app/e2e/shell/editor-annotations.spec.ts index ffc5866e..3517ced6 100644 --- a/apps/app/e2e/shell/editor-annotations.spec.ts +++ b/apps/app/e2e/shell/editor-annotations.spec.ts @@ -416,6 +416,30 @@ test.describe('editor annotations (A3)', () => { .first() .evaluate((span) => span.scrollWidth > span.clientWidth) expect(cut, 'the message is cut short').toBe(false) + // M-5: « Défaire » answers 44 px tall below xl (36 px from xl), the pill unchanged. + const reach = width < 1280 ? 44 : 36 + const hit = await line(page) + .getByRole('button', { name: dict['editor.history.undo_title'] }) + .evaluate( + (button, half) => { + const box = button.getBoundingClientRect() + const x = box.left + box.width / 2 + const mid = box.top + box.height / 2 + const at = (dy: number) => document.elementFromPoint(x, mid + dy) + const pill = button.closest('[data-testid="gesture-message"]')! + return { + top: at(-half) === button, + bottom: at(half) === button, + pill: pill.getBoundingClientRect().height, + } + }, + reach / 2 - 1, + ) + expect(hit, `a ${reach} px hit area at ${width} px`).toEqual({ + top: true, + bottom: true, + pill: 36, + }) // Its expiry, 6 s later. await expectNoShift(page, async () => { await page.clock.fastForward(6_100) diff --git a/apps/app/src/components/editor/annotations/EditStrip.tsx b/apps/app/src/components/editor/annotations/EditStrip.tsx index 0e0129d0..90f14d6c 100644 --- a/apps/app/src/components/editor/annotations/EditStrip.tsx +++ b/apps/app/src/components/editor/annotations/EditStrip.tsx @@ -42,12 +42,12 @@ export default function EditStrip({ className="flex h-16 items-center gap-3 overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] px-3" > -
- {notice && } +
+ {/* M-3: the polite region always mounted; an alert beside it, never inside. */} +
+ {notice && !alerts(notice) && } +
+ {notice && alerts(notice) && }
{commands} @@ -91,11 +91,14 @@ function Lead({ lead }: { lead: StripLead }) { ) } +/** A refusal not already announced by the gesture line. */ +const alerts = (notice: StripNotice) => notice.tone === 'error' && !notice.quiet + function Notice({ notice }: { notice: StripNotice }) { const error = notice.tone === 'error' return (

{children}

- +
+ {message && !error && ( + + )} +
+ {message && error && ( + + )}
) } -function Message({ messages }: { messages: GestureMessages }) { +/** + * One pill. Each message is another pill (keyed by its serial): a wider one replacing it + * moves no box (A14), and a repeated refusal is announced again (M-3). + */ +function Message({ + messages, + shown, +}: { + messages: GestureMessages + shown: Shown +}) { const t = useT() const readOnly = useEditorReadOnly() // A12: « Défaire » is hidden during a creation; the message itself stays. const creating = useAnnotationWork((s) => s.creation !== null) - const { message, hold } = messages - if (!message) return null - const error = message.tone === 'error' - const { stamp } = message + const error = shown.tone === 'error' return (

- - {message.text} + + {shown.text} - {message.undo && !error && !creating && ( + {shown.undo && !error && !creating && ( <>