fix(editor): message line lifecycle, own row, sound no-shift check
Task 3 review, fix round 1. - The gesture message closes for good on any document or history change (store subscription): undo then redo no longer revives it. - Hover and focus hold only the message they were taken on: after « Défaire » the next message expires. - An accepted drop clears the strip's refusal hint again. - Controller ruling: the message has its own fixed row under the add buttons, column width; a refused gesture's full text also shows in the strip notice (red, aria-hidden copy of the row's alert). - expectNoShift: native requestAnimationFrame kept before page.clock (keepNativeFrames), every part box asserted non-null, message row measured; the e2e checks the message is not truncated. No assertion removed; the refused-drop unit test gains the strip copy.
This commit is contained in:
1 parent
1deb037fac
commit
7a45f1d885
9 files changed
+198
-49
No files matched your search
@@ -12,6 +12,8 @@ export interface StripNotice {
|
||||
/** How many more of the same kind are not shown (« +n »). */
|
||||
more?: number
|
||||
link?: { label: string; onClick(): void }
|
||||
/** Already announced elsewhere (the gesture line's alert): shown, not announced twice. */
|
||||
quiet?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +88,8 @@ function Notice({ notice }: { notice: StripNotice }) {
|
||||
const error = notice.tone === 'error'
|
||||
return (
|
||||
<p
|
||||
role={error ? 'alert' : undefined}
|
||||
role={error && !notice.quiet ? 'alert' : undefined}
|
||||
aria-hidden={notice.quiet || undefined}
|
||||
className={`flex min-w-0 items-start gap-1 text-xs ${
|
||||
error
|
||||
? 'text-[var(--color-danger-strong)]'
|
||||
|
||||
@@ -14,6 +14,7 @@ import { usePlacement } from '@/editor/annotations/usePlacement'
|
||||
import { stripLeadOf } from '@/editor/annotations/stripLead'
|
||||
import {
|
||||
useGestureMessage,
|
||||
type GestureMessage as ShownMessage,
|
||||
type GestureMessages,
|
||||
} from '@/editor/annotations/useGestureMessage'
|
||||
import {
|
||||
@@ -152,7 +153,7 @@ export default function EditableAnnotations(props: Props) {
|
||||
)
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<SceneStrip scene={scene} placement={placement} />
|
||||
<SceneStrip scene={scene} placement={placement} message={message} />
|
||||
<div className="grid gap-4 lg:grid-cols-[minmax(0,1fr)_22rem]">
|
||||
<CanvasColumn
|
||||
scene={scene}
|
||||
@@ -336,13 +337,15 @@ function overlayOf(
|
||||
function SceneStrip({
|
||||
scene,
|
||||
placement,
|
||||
message,
|
||||
}: {
|
||||
scene: Scene
|
||||
placement: Placement
|
||||
message: GestureMessages
|
||||
}) {
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const notice = useStripNotice(scene)
|
||||
const notice = useStripNotice(scene, message.message)
|
||||
const { ui, selected, doc } = scene
|
||||
return (
|
||||
<EditStrip
|
||||
@@ -362,14 +365,21 @@ function SceneStrip({
|
||||
}
|
||||
|
||||
/**
|
||||
* The strip's middle, first match wins: a refusal, the selection's geometry issues (the
|
||||
* first, then « +n »), then why a tool cannot be used now.
|
||||
* 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.
|
||||
*/
|
||||
function useStripNotice(scene: Scene): StripNotice | null {
|
||||
function useStripNotice(
|
||||
scene: Scene,
|
||||
message: ShownMessage | null,
|
||||
): StripNotice | null {
|
||||
const t = useT()
|
||||
const issues = useGeometryIssues(scene.selected?.id ?? '')
|
||||
const { ui, model, doc } = scene
|
||||
if (ui.hint) return { tone: 'error', text: ui.hint }
|
||||
if (message?.tone === 'error') {
|
||||
return { tone: 'error', text: message.text, quiet: true }
|
||||
}
|
||||
if (scene.selected && issues.length > 0) {
|
||||
return { tone: 'error', text: issues[0]!, more: issues.length - 1 }
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import type { GestureMessages } from '@/editor/annotations/useGestureMessage'
|
||||
import { canUndo, useEditorStore } from '@/editor/state/editorStore'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
// Compact: at 1 280 px the column leaves about 145 px beside the three add buttons.
|
||||
const PILL =
|
||||
'inline-flex h-9 max-w-full items-center gap-1.5 rounded-md px-2 text-xs'
|
||||
'inline-flex h-9 max-w-full items-center gap-2 rounded-md px-3 text-sm'
|
||||
|
||||
/** The header's undo (T15): the same store step, under the same conditions. */
|
||||
function undoLast(readOnly: boolean): void {
|
||||
@@ -15,9 +14,10 @@ function undoLast(readOnly: boolean): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* The fixed line under the drawing (A14, R-2): the add buttons on the left, the message on
|
||||
* the right, one line truncated. Its height never changes, so a message showing or leaving
|
||||
* moves nothing. The status region (polite) is always mounted; a refusal is an alert of its own.
|
||||
* Under the drawing (A14, R-2): the add buttons, then the message on a row of its own, the
|
||||
* drawing column's full width, one line truncated. The row is always there at a fixed
|
||||
* height, so a message showing or leaving moves nothing. The status region (polite) is
|
||||
* always mounted; a refusal is an alert of its own (its full text is also in the strip).
|
||||
*/
|
||||
export default function GestureMessage({
|
||||
messages,
|
||||
@@ -27,18 +27,16 @@ export default function GestureMessage({
|
||||
children: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
data-testid="gesture-line"
|
||||
className="flex h-11 items-center gap-2 overflow-hidden"
|
||||
>
|
||||
<div className="shrink-0">{children}</div>
|
||||
<>
|
||||
{children}
|
||||
<div
|
||||
data-testid="gesture-line"
|
||||
role="status"
|
||||
className="flex min-w-0 flex-1 justify-end py-1 pr-0.5"
|
||||
className="flex h-11 items-center justify-end overflow-hidden px-1"
|
||||
>
|
||||
<Message messages={messages} />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -64,6 +62,7 @@ function Message({ messages }: { messages: GestureMessages }) {
|
||||
</span>
|
||||
{message.undo && !error && (
|
||||
<>
|
||||
<span aria-hidden="true">·</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('editor.history.undo_title')}
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function KeyboardAdd({
|
||||
}) {
|
||||
const t = useT()
|
||||
return (
|
||||
<div className="flex flex-nowrap gap-2">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{KINDS.map((kind) => (
|
||||
<Button
|
||||
key={kind}
|
||||
|
||||
Reference in new issue
Block a user