Open the remove confirm on Cancel, not on Remove

Moving focus into an opened confirm row took the first button in DOM order,
which is the affirmative in all three rows — so the one irreversible action
opened with its destructive button pre-armed and a stray Enter would fire it.
That inverts the point of the gate the row exists to be.

The reversible rows still open on their affirmative; remove opens on Cancel.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-30 22:15:43 +07:00
parent f22db44c35
commit 95c374976b
+6 -1
View File
@@ -106,7 +106,12 @@ function toggleConfirmRow(key, kind) {
// unhides: it makes the announcement deterministic, keeps tab order inside
// the confirm instead of running on into the next card, and means the row
// cannot be opened and scrolled past unnoticed.
if (row && !row.hidden) row.querySelector("button").focus();
// The reversible rows open on their affirmative; remove opens on Cancel.
// Focusing the first button in DOM order would hand the irreversible action
// a pre-armed Enter, which is the opposite of what a confirm gate is for.
if (row && !row.hidden) {
row.querySelector(row.classList.contains("calm") ? "button" : "button + button").focus();
}
}
// Esc closes whichever panel this card has open and hands focus back to the