web: shared modal focus controller (M1/M2) — work in progress

This commit is contained in:
2026-10-19 20:46:15 +01:00
parent a7991077d2
commit b1e9400d6e
11 changed files with 1562 additions and 121 deletions
+12 -4
View File
@@ -37,7 +37,7 @@ export function loadNotifyAsked() {
}
export function createAttentionView(rt) {
const { state, attentionLayer, runAlerts } = rt;
const { state, attentionLayer, runAlerts, modal } = rt;
const render = (...args) => rt.render(...args);
const selectRun = (...args) => rt.selectRun(...args);
@@ -126,6 +126,7 @@ function refreshAttentionBell() {
function renderAttentionSheet() {
if (!state.attentionSheetOpen) {
attentionLayer.replaceChildren();
modal.close("attention-sheet");
return;
}
const entries = attentionEntries(state.runs, state.attentionDismissed);
@@ -175,6 +176,14 @@ function renderAttentionSheet() {
const sheet = h("div", { class: "attention-sheet-panel", tabindex: "-1" }, head, body);
overlay.append(sheet);
attentionLayer.replaceChildren(overlay);
modal.open("attention-sheet", overlay, {
// The sheet is rebuilt by renderAttentionSheet, not by renderContent's
// staged set, so it is managed imperatively rather than reconciled away.
renderManaged: false,
onClose: () => closeAttentionSheet(),
triggerSelector: "#attentionBell",
fallbackSelectors: ["#listTitle", "#pane-main"],
});
}
/** One attention row: status icon, the two text lines, and a trailing Dismiss. */
@@ -227,16 +236,15 @@ function openAttentionSheet() {
attentionEntries(state.runs, state.attentionDismissed),
);
render();
document.querySelector(".attention-sheet-close")?.focus();
}
/** Close the sheet, dropping the snapshot; focus returns to the bell. */
/** Close the sheet, dropping the snapshot; the controller returns focus to the bell. */
function closeAttentionSheet({ restoreFocus = true } = {}) {
if (!state.attentionSheetOpen) return;
state.attentionSheetOpen = false;
state.attentionSnapshot = null;
if (!restoreFocus) modal.close("attention-sheet", { restoreFocus: false });
render();
if (restoreFocus) document.querySelector("#attentionBell")?.focus();
}
/** Dismiss one or more entries for good, persisting the identity set. */