fix(ui): step card header is a keyboard-operable button, Edit in its menu (#1735)

The step header in StepNode.vue was a div with @click and no role, so a
step could not be opened from the keyboard, and Edit existed only in the
right-click canvas menu. The header now renders as a real <button> (with
aria-expanded) whenever the step can toggle, so Tab/Enter/Space open it;
while renaming it stays a div so the rename input is not nested inside a
button. The actions menu trigger moved to an absolute overlay at the
card's top-right (same spot as before, with a matching spacer in the
header row) and gained an Edit item that toggles the step, matching the
canvas context menu.
This commit is contained in:
sam committed 2026-11-06 21:48:55 +11:00
1 parent c5a43f21aa
commit d90f7d48d0
1 file changed
+26 -14
+26 -14
View File
@@ -110,12 +110,22 @@ function commitRename(event: Event): void {
<template>
<div
ref="card"
class="rounded-lg border bg-card text-left shadow-sm transition-[width,box-shadow] duration-200"
class="relative rounded-lg border bg-card text-left shadow-sm transition-[width,box-shadow] duration-200"
:class="[stateClass, data.expanded ? 'w-[26rem] shadow-lg ring-2 ring-ring' : 'w-60 hover:border-muted-foreground', data.onToggle && 'cursor-pointer']"
>
<Handle v-if="data.kind !== 'workflow'" type="target" :position="Position.Top" />
<Handle id="data-in" type="target" :position="Position.Right" class="!opacity-0" />
<div class="px-3 py-2.5" @click="data.onToggle?.()">
<!-- The header is a real button when the step can toggle, so Tab, Enter
and Space open it. While renaming it stays a div, keeping the rename
input valid HTML (no interactive content inside a button). -->
<component
:is="data.onToggle && !renaming ? 'button' : 'div'"
:type="data.onToggle && !renaming ? 'button' : undefined"
class="nodrag nopan block w-full px-3 py-2.5 text-left"
:class="data.onToggle && !renaming && 'cursor-pointer'"
:aria-expanded="data.onToggle ? String(!!data.expanded) : undefined"
@click="data.onToggle?.()"
>
<div class="flex items-center gap-1.5">
<Badge variant="outline" class="max-w-40 gap-1 bg-background">
<component :is="badge.icon" class="text-link" aria-hidden="true" /><span class="truncate" :title="badge.label">{{ badge.label }}</span>
@@ -123,17 +133,7 @@ function commitRename(event: Event): void {
<span v-if="data.run?.duration_ms !== undefined" class="ml-auto font-mono text-caption text-fg-subtle">{{ duration(data.run.duration_ms) }}</span>
<component :is="status.icon" v-if="status" class="size-4 shrink-0" :class="[status.class, data.run?.duration_ms === undefined && 'ml-auto']" :aria-label="status.label" :title="data.run?.error || status.label" />
<span v-else class="ml-auto" />
<DropdownMenu v-if="data.editable && data.kind === 'step'">
<DropdownMenuTrigger as-child>
<Button variant="ghost" size="icon-xs" class="nodrag nopan -mr-1.5" aria-label="Step actions" @click.stop><EllipsisVertical /></Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" class="w-40">
<DropdownMenuItem @select="rename"><Pencil />Rename</DropdownMenuItem>
<DropdownMenuItem v-if="!['parallel', 'switch'].includes(data.type)" @select="data.onDuplicate?.()"><Copy />Duplicate</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive" @select="data.onRemove?.()"><Trash2 />Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<span v-if="data.editable && data.kind === 'step'" class="-mr-1.5 w-6 shrink-0" aria-hidden="true" />
</div>
<div class="mt-1.5 flex min-w-0 items-baseline gap-1 text-sm font-medium">
<span v-if="number" class="shrink-0">{{ number }}</span>
@@ -173,7 +173,19 @@ function commitRename(event: Event): void {
</div>
<p v-if="data.run?.error" class="mt-1 line-clamp-2 text-caption text-danger" :title="data.run.error">{{ data.run.error }}</p>
</template>
</div>
</component>
<DropdownMenu v-if="data.editable && data.kind === 'step'">
<DropdownMenuTrigger as-child>
<Button variant="ghost" size="icon-xs" class="nodrag nopan absolute top-2.5 right-1.5" aria-label="Step actions" @click.stop><EllipsisVertical /></Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" class="w-40">
<DropdownMenuItem @select="data.onToggle?.()"><Pencil />Edit</DropdownMenuItem>
<DropdownMenuItem @select="rename"><Pencil />Rename</DropdownMenuItem>
<DropdownMenuItem v-if="!['parallel', 'switch'].includes(data.type)" @select="data.onDuplicate?.()"><Copy />Duplicate</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive" @select="data.onRemove?.()"><Trash2 />Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<Transition enter-from-class="opacity-0 -translate-y-1" enter-active-class="transition duration-200" leave-to-class="opacity-0" leave-active-class="transition duration-100">
<div v-if="data.expanded" class="nodrag nopan nowheel cursor-auto border-t border-border" @click.stop>
<slot />