Skip to content

Dashboard-tree's orphaned-variable delete confirm autofocuses the destructive action, not Cancel #501

Description

@BorisTyshkevich

The gap

dashboard-tree.ts's buildDeleteButton (the orphaned-variable's trash
confirm, dashboard-tree.ts:779) opens its openMenu confirm with the same
row order #466 just fixed in tabs.ts's requestCloseTab: the destructive
item ("Delete option SQL") listed before "Cancel". openMenu autofocuses the
first focusable row by default, so a keyboard user who opens this confirm and
immediately presses Enter — the browser's native focused-button activation —
deletes the stored SQL by default, with no per-variable undo.

#466 (PR #499) added MenuRow.item.autofocus?: boolean to src/ui/menu.ts
specifically so a caller can keep the destructive-first visual order (the
convention buildDeleteButton itself established) while still defaulting
keyboard focus to Cancel. Fixing this instance is a one-line addition:
autofocus: true on buildDeleteButton's own { kind: 'item', label: 'Cancel', ... } row (dashboard-tree.ts ~line 813).

Why deferred

Out of scope for #466, which only touches the tab strip's own close confirm.
Surfaced by an independent code-review pass on that PR, which explicitly
flagged that fixing the new call site without touching this pre-existing one
would leave the identical risk in place. A dashboard-tree.test.ts (or e2e)
regression test asserting the Cancel button is the initially-focused element
should land in the same change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    inboxFiled mid-task; not yet triaged into the roadmap

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions