, which
// neither ref matches — native Tab order must not be allowed to resume
// from the top of the document into the page behind the backdrop.
// Reclaim focus onto Cancel rather than enumerating known positions.
if (!$el.contains(document.activeElement)) {
$event.preventDefault();
$refs.cancelBtn.focus();
return;
}
// In-dialog case: wrap between the two known focusable elements
// (Cancel/Confirm). Assumption: the dialog only ever contains these two
// buttons. `message` and `subject` are both rendered via x-text, never
// x-html, so neither can ever inject focusable markup (a link, a button)
// — the hazard this comment used to warn about is now structurally
// impossible, not just avoided by convention. The two hardcoded refs are
// therefore safe to keep as-is; no dynamic query of the dialog's focusable
// descendants is needed unless a *third* focusable control is added to the
// dialog body itself.
if ($event.shiftKey) {
if (document.activeElement === $refs.cancelBtn) { $event.preventDefault(); $refs.confirmBtn.focus(); }
} else if (document.activeElement === $refs.confirmBtn) {
$event.preventDefault(); $refs.cancelBtn.focus();
}
">