[Bug]: Pressing Enter in a confirmation dialog cancels instead of confirming#18167

openedOct 11, 2026byRrgrvlsk

Scope update (2026-10-11 12:12 UTC), after the maintainer's reply: the fix follows the approved initialFocus approach with targeted call sites: the desktop and server update prompts, relay client install, and the browser import "quit" and "try again" steps (#18187). Destructive confirms keep Cancel focused, which includes "remove a hub" (that example below was wrong: its action is destructive). PR stack merge/rebase, reset credits and other non-destructive confirms are left for follow-ups.

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Trigger any confirmation dialog. For example, wait for the desktop update prompt ("Install update … and restart T3 Code?"), or go to Settings → Usage and remove a hub.
  2. Without touching the mouse, press Enter.

Expected behavior

I'd expect Enter to activate Confirm, since it's the button highlighted as the primary action.

Actual behavior

The dialog closes as if Cancel had been pressed. Space does the same.

As far as I can tell, this happens because focus lands on Cancel, the first button, when the dialog opens. So Enter and Space activate Cancel, even though Confirm is the one that looks like the default.

The same thing seems to happen in:

  • every AlertDialog;
  • a few plain Dialog confirmations: merge or rebase a PR stack, install the relay client, and the browser import "quit" and "try again" steps.

Impact

Minor bug or occasional failure

Version or commit

Seen in the desktop Nightly while it offered 0.0.46-nightly; reproduced on main @ 98beed1a22

Environment

macOS, T3 Code Nightly desktop app; also reproduced in Chrome against a local dev build of main

Logs or stack traces

shell
1

Screenshots, recordings, or supporting files

before-default.png

Workaround

Press Tab to move focus to Confirm before pressing Enter, or click Confirm.

A possible fix, if it helps

I'm happy to help with this, though I'd rather check with you first that it's the direction you want. One option that seemed small and safe: when a dialog opens, focus its primary action, using Base UI's initialFocus.

  • Enter and Space would confirm, Esc would still cancel, and Tab would reach Cancel. That's the standard button behavior the WAI-ARIA alert dialog pattern describes, and roughly what Windows message boxes do.
  • Destructive confirmations would keep focus on Cancel, so running a destructive action would still need a deliberate Tab.

I have a small PR along these lines ready. I'll only open it if you think this approach makes sense.

One open question, about macOS: native macOS alerts go a step further. Return runs the default button even when focus is on another button, and Space activates the focused one. I didn't go that way, because on the web a focused button is expected to respond to Enter, and screen reader users rely on that. If you'd prefer the macOS behavior in the desktop app, I'd be glad to add a small layer limited to macOS on top of this.

Thank you for T3 Code, and for taking a look!

Note

Grok responding on behalf of Julius.

This is a real keyboard/focus mismatch on main, not intentional Cancel-first behavior.

AlertDialogPopup / DialogPopup never set initialFocus. Base UI therefore focuses the first tabbable element (docs). Confirm footers put Cancel first in the DOM (ConfirmDialogHost, Usage remove-hub, relay install, etc.), so Enter/Space hit Cancel even when Confirm is the highlighted primary. That matches your repro on main.

Related history:

  • #17881 (same author, closed unmerged) took a broader path: shared Enter handling in the dialog primitives across many confirmation flows (including merge/branch/credits) and touched a Clerk/auth dialog. Macroscope marked it not approvable for that blast radius. Please do not reopen that approach.
  • #12526 already treated “Enter should activate the highlighted primary action” as a bug in the PR checkout dialog, so the direction is consistent with prior fixes.

Worth inviting as a PR: yes — the narrower Base UI initialFocus approach (focus the primary action on open; keep Cancel focused for destructive* confirms; Esc still cancels; Tab still reaches Cancel). That stays in the focus path, avoids a global Enter interceptor, and lines up with the WAI-ARIA alertdialog pattern. Prefer a small change in the dialog primitives plus targeted call sites over another 20+ file Enter-routing PR.

Optional macOS “Return always runs the default button” layer can be a follow-up; web/a11y Enter-on-focused-control is the right default for the first PR.

Checked main 70e5e384da in Chromium 154 on Linux, 1280×800, DPR 2, with isolated dev state. The literal desktop-update path is unavailable here; Usage has no configured hubs.

With a synthetic trigger through the real app’s requestConfirmDialog coordinator using the update prompt text, focus lands on Cancel; Enter resolves false. A second attempt with Space also resolves false. This verifies the shared dialog behavior, not the desktop update entry point.

Recording: open dialog, then Enter cancels

The existing fix #18187 is already under maintainer takeover. Leaving this issue open for that work; no competing PR.

Fresh check on main 8acbefefc5, Chromium 154 on Linux, 1280×800, DPR 2, isolated dev state:

  • Desktop update prompt: unavailable in this web environment. Usage: no configured hubs to remove.
  • Through the real app’s requestConfirmDialog coordinator, opened “Install update 0.0.46-nightly and restart T3 Code?” without moving focus. Cancel receives focus. Enter resolves false; reopening and pressing Space also resolves false.
  • Real-data seeding failed on a migration-history mismatch, so this attempt used fresh state. This proves shared-dialog behavior, not the desktop update entry point.

Recording: first opening → Enter cancels; second opening → Space cancels

Existing fix #18187 is already under maintainer takeover. Preserved that work; no competing PR. Leaving the issue open for the existing fix.